From 950a6f4192fbfeb702888b5822aa302e13402674 Mon Sep 17 00:00:00 2001 From: Alain Kadar Date: Wed, 10 Aug 2022 16:18:36 -0400 Subject: [PATCH 01/10] First pass --- doc/api.rst | 1 + signac/contrib/job.py | 5 +++++ tests/test_job.py | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/doc/api.rst b/doc/api.rst index f4ca03292..a139d0944 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -90,6 +90,7 @@ The Job class Job.move Job.open Job.path + Job.project Job.remove Job.reset Job.sp diff --git a/signac/contrib/job.py b/signac/contrib/job.py index 441d9fdf4..5a46d4e62 100644 --- a/signac/contrib/job.py +++ b/signac/contrib/job.py @@ -605,6 +605,11 @@ def data(self, new_data): """ self.stores[self.KEY_DATA] = new_data + + @property + def project(self): + """Return the project that contains this job.""" + return self._project def init(self, force=False): """Initialize the job's workspace directory. diff --git a/tests/test_job.py b/tests/test_job.py index 2fea1520e..7ed34011f 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -238,6 +238,11 @@ def test_deepcopy(self): copied_job.sp.a = 3 assert copied_job in self.project + def test_project(self): + job = self.project.open_job({"a": 0}) + assert isinstance(job.project, signac.Project) + assert job in job.project + assert job.project.path == self._tmp_pr class TestJobSpInterface(TestJobBase): def test_interface_read_only(self): From ae80038734b4e598f9a2e837d3932e5ae0f54a9a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Aug 2022 20:21:49 +0000 Subject: [PATCH 02/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- signac/contrib/job.py | 2 +- tests/test_job.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/signac/contrib/job.py b/signac/contrib/job.py index 5a46d4e62..e3af5f162 100644 --- a/signac/contrib/job.py +++ b/signac/contrib/job.py @@ -605,7 +605,7 @@ def data(self, new_data): """ self.stores[self.KEY_DATA] = new_data - + @property def project(self): """Return the project that contains this job.""" diff --git a/tests/test_job.py b/tests/test_job.py index 7ed34011f..d1e9ac6f6 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -244,6 +244,7 @@ def test_project(self): assert job in job.project assert job.project.path == self._tmp_pr + class TestJobSpInterface(TestJobBase): def test_interface_read_only(self): sp = self.nested_dict() From 36968138bbbdb1dbf34081024e372a965caed479 Mon Sep 17 00:00:00 2001 From: Alain Kadar Date: Sat, 20 Aug 2022 12:04:41 -0400 Subject: [PATCH 03/10] Initialize job --- signac/contrib/job.py | 8 +++++++- tests/test_job.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/signac/contrib/job.py b/signac/contrib/job.py index e3af5f162..d85f340cc 100644 --- a/signac/contrib/job.py +++ b/signac/contrib/job.py @@ -608,7 +608,13 @@ def data(self, new_data): @property def project(self): - """Return the project that contains this job.""" + """Get the project that contains this job. + + Returns + ------- + signac.Project + Returns the project containing this job. + """ return self._project def init(self, force=False): diff --git a/tests/test_job.py b/tests/test_job.py index d1e9ac6f6..366675212 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -239,7 +239,7 @@ def test_deepcopy(self): assert copied_job in self.project def test_project(self): - job = self.project.open_job({"a": 0}) + job = self.project.open_job({"a": 0}).init() assert isinstance(job.project, signac.Project) assert job in job.project assert job.project.path == self._tmp_pr From 31ea7b86e81b9f9560bfb8baf1d1027b5a9aa5d7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 Aug 2022 16:05:09 +0000 Subject: [PATCH 04/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- signac/contrib/job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signac/contrib/job.py b/signac/contrib/job.py index d85f340cc..8083aaa72 100644 --- a/signac/contrib/job.py +++ b/signac/contrib/job.py @@ -609,7 +609,7 @@ def data(self, new_data): @property def project(self): """Get the project that contains this job. - + Returns ------- signac.Project From aefad4ff24e0498889fc6d298f017367c83650ed Mon Sep 17 00:00:00 2001 From: Hardik Ojha <44747868+kidrahahjo@users.noreply.github.com> Date: Wed, 24 Aug 2022 22:55:30 +0530 Subject: [PATCH 05/10] Update tests/test_job.py --- tests/test_job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_job.py b/tests/test_job.py index 366675212..9abddf695 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -238,7 +238,7 @@ def test_deepcopy(self): copied_job.sp.a = 3 assert copied_job in self.project - def test_project(self): + def test_project_access_from_job(self): job = self.project.open_job({"a": 0}).init() assert isinstance(job.project, signac.Project) assert job in job.project From 194a8e194a010529304a3946d024f7d5252e253a Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 25 Aug 2022 19:38:42 -0500 Subject: [PATCH 06/10] Add test for custom Project subclass. --- tests/test_job.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_job.py b/tests/test_job.py index 9abddf695..5ac0d9086 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -244,6 +244,16 @@ def test_project_access_from_job(self): assert job in job.project assert job.project.path == self._tmp_pr + def test_custom_project_access_from_job(self): + # Test a custom project subclass to ensure compatibility with signac-flow's FlowProject + class CustomProject(signac.Project): + pass + custom_project = CustomProject.get_project(self._tmp_pr) + job2 = custom_project.open_job({"a": 0}).init() + assert isinstance(job2.project, CustomProject) + assert job2 in custom_project + assert job2.project.path == self._tmp_pr + class TestJobSpInterface(TestJobBase): def test_interface_read_only(self): From 02f2ac1d9fd2cf5ef1abd1eab671151c3fdc8ac8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Aug 2022 00:39:07 +0000 Subject: [PATCH 07/10] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_job.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_job.py b/tests/test_job.py index 5ac0d9086..4f2dbf885 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -248,6 +248,7 @@ def test_custom_project_access_from_job(self): # Test a custom project subclass to ensure compatibility with signac-flow's FlowProject class CustomProject(signac.Project): pass + custom_project = CustomProject.get_project(self._tmp_pr) job2 = custom_project.open_job({"a": 0}).init() assert isinstance(job2.project, CustomProject) From a05712c256257d63863d845b67c3d65384032e76 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Thu, 25 Aug 2022 19:40:46 -0500 Subject: [PATCH 08/10] Fix test. --- tests/test_job.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_job.py b/tests/test_job.py index 4f2dbf885..70ff08db4 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -250,10 +250,10 @@ class CustomProject(signac.Project): pass custom_project = CustomProject.get_project(self._tmp_pr) - job2 = custom_project.open_job({"a": 0}).init() - assert isinstance(job2.project, CustomProject) - assert job2 in custom_project - assert job2.project.path == self._tmp_pr + job = custom_project.open_job({"a": 0}).init() + assert isinstance(job.project, CustomProject) + assert job in job.project + assert job.project.path == self._tmp_pr class TestJobSpInterface(TestJobBase): From 156a83b5f18d1e9f6826f21cd06549556d91a5ff Mon Sep 17 00:00:00 2001 From: Alain Kadar Date: Mon, 29 Aug 2022 17:16:42 -0400 Subject: [PATCH 09/10] Update changelog and contributors --- changelog.txt | 2 +- contributors.yaml | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 98bae35f0..64aa24b9d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -13,7 +13,7 @@ Version 2 Added +++++ - ``H5Store`` related errors are now included in the public API (#775). - + - Users can now access the project which a job belongs to from the job object. Changed +++++++ diff --git a/contributors.yaml b/contributors.yaml index d47b4cca0..0c70154d9 100644 --- a/contributors.yaml +++ b/contributors.yaml @@ -123,4 +123,8 @@ contributors: family-names: Takada given-names: Kody affiliation: "University of Michigan" + - + family-names: Kadar + given-names: Alain + affiliation: "University of Michigan" ... From 5783d30bf3e58cd57dd69662393e3b9c7a218261 Mon Sep 17 00:00:00 2001 From: Alain Kadar Date: Mon, 29 Aug 2022 17:19:12 -0400 Subject: [PATCH 10/10] Formatting --- changelog.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index 64aa24b9d..ff06b9669 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,8 +12,10 @@ Version 2 Added +++++ + - ``H5Store`` related errors are now included in the public API (#775). - Users can now access the project which a job belongs to from the job object. + Changed +++++++