Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Revert save overload #234

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions pyiron_workflow/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import os
import sys

from pyiron_base import GenericJob, TemplateJob, JOB_CLASS_DICT
from pyiron_base import TemplateJob, JOB_CLASS_DICT
from pyiron_base.jobs.flex.pythonfunctioncontainer import (
PythonFunctionContainerJob,
get_function_parameter_dict,
Expand Down Expand Up @@ -122,17 +122,6 @@ def run_static(self):
self.to_hdf()
self.status.finished = True

def save(self):
# PythonFunctionContainerJob.save assumes that the job is being created
# exclusively from pyiron_base.Project.wrap_python_function, and therefore
# always dynamically renames the job based on the wrapped function and the
# input.
# Here, the jobs are created in the usual way, with the usual use of job name,
# so it is just confusing if this renaming happens; thus, we save as usual.
# If at any point PythonFunctionContainerJob.save behaves in the usual way,
# this override can be removed
GenericJob.save(self)


JOB_CLASS_DICT[NodeOutputJob.__name__] = NodeOutputJob.__module__

Expand Down
32 changes: 2 additions & 30 deletions tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,11 @@ def tearDown(self) -> None:


class TestNodeOutputJob(_WithAJob):
def make_a_job_from_node(self, node, job_name=None):
job = self.pr.create.job.NodeOutputJob(
node.label if job_name is None else job_name
)
def make_a_job_from_node(self, node):
job = self.pr.create.job.NodeOutputJob(node.label)
job.input["node"] = node
return job

@unittest.skipIf(sys.version_info < (3, 11), "Storage will only work in 3.11+")
def test_job_name_override(self):
job_name = "my_name"
job = self.make_a_job_from_node(
Workflow.create.standard.UserInput(42),
job_name=job_name
)
self.assertEqual(
job_name,
job.job_name,
msg="Sanity check"
)
try:
job.save()
self.assertEqual(
job_name,
job.job_name,
msg="Standard behaviour for the parent class is to dynamically rename "
"the job at save time; since we create these jobs as usual from "
"the job creator, this is just confusing and we want to avoid it. "
"If this behaviour is every changed in pyiron_base, the override "
"and this test can both be removed."
)
finally:
job.remove()

@unittest.skipIf(sys.version_info >= (3, 11), "Storage should only work in 3.11+")
def test_clean_failure(self):
with self.assertRaises(
Expand Down
Loading