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

doc/bettter document update and reset statepoint #444

Merged
merged 24 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cdc39e8
grammar fix
cbkerr Dec 23, 2020
9c8ff91
explaing update_statepoint without using the word update
cbkerr Dec 23, 2020
af7b95a
grammar fix
cbkerr Dec 23, 2020
c865a37
noting that update_statepoint with overwrite=True is reset_statepoint
cbkerr Dec 23, 2020
68f3d1f
explaing reset_statetpoint without the word reset
cbkerr Dec 23, 2020
c5db8e9
add links to main signac-docs
cbkerr Dec 23, 2020
0200ada
Merge branch 'master' into doc/bettter-document-reset
cbkerr Dec 23, 2020
9309616
add noqa for long line url
cbkerr Dec 23, 2020
baf77d9
move noqa to end of docstring
cbkerr Dec 23, 2020
aee8cd3
Merge branch 'master' into doc/bettter-document-reset
bdice Dec 28, 2020
5b8fd1a
expand phrase into sentence from code review
cbkerr Dec 29, 2020
23ac203
improve wording of overwrite argument docstring
cbkerr Dec 29, 2020
661f13c
fix whitespace
cbkerr Dec 29, 2020
192db01
Merge branch 'master' into doc/bettter-document-reset
bdice Dec 31, 2020
dfe5e5d
apply documentation changes to deprecated equivalent methods
cbkerr Dec 31, 2020
daedb33
Merge branch 'master' into doc/bettter-document-reset
bdice Jan 3, 2021
de55418
Merge branch 'master' into doc/bettter-document-reset
vyasr Jan 5, 2021
1c4d1ac
suggestions from code review
cbkerr Jan 22, 2021
369ddc2
Merge branch 'master' into doc/bettter-document-reset
cbkerr Jan 22, 2021
3d97c3e
Update docstring parameters.
bdice Jan 22, 2021
cab21d6
Update docstrings.
bdice Jan 22, 2021
ad8ab00
Add missing statement.
bdice Jan 22, 2021
49c19c8
Fix all Sphinx references to errors, add missing errors to public nam…
bdice Jan 22, 2021
915eacc
Merge branch 'master' into doc/bettter-document-reset
bdice Jan 23, 2021
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
2 changes: 1 addition & 1 deletion signac/contrib/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _build_index(docs, key, primary_key):

Raises
------
InvalidKeyError
:class:`~signac.errors.InvalidKeyError`
The document contains invalid keys.

"""
Expand Down
12 changes: 6 additions & 6 deletions signac/contrib/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def _check(path):

Raises
------
StatepointParsingError
:class:`~signac.errors.StatepointParsingError`
If identified state point conflicts with state point in job manifest file.

"""
Expand Down Expand Up @@ -817,7 +817,7 @@ def _analyze_directory_for_import(root, project, schema):
------
TypeError
If the schema given is not None, callable, or a string.
StatepointParsingError
:class:`~signac.errors.StatepointParsingError`
If the jobs identified with the given schema function are not unique.

"""
Expand Down Expand Up @@ -910,9 +910,9 @@ def _analyze_zipfile_for_import(zipfile, project, schema):
------
TypeError
If the schema provided is not None, callable, or a string.
DestinationExistsError
:class:`~signac.errors.DestinationExistsError`
If a job is already initialized.
StatepointParsingError
:class:`~signac.errors.StatepointParsingError`
If the jobs identified with the given schema function are not unique.

"""
Expand Down Expand Up @@ -1055,9 +1055,9 @@ def _analyze_tarfile_for_import(tarfile, project, schema, tmpdir):
------
TypeError
If the schema given is not None, callable, or a string.
DestinationExistsError
:class:`~signac.errors.DestinationExistsError`
If a job is already initialized.
StatepointParsingError
:class:`~signac.errors.StatepointParsingError`
If the jobs identified with the given schema function are not unique.
AssertionError
If ``tmpdir`` given is not a directory.
Expand Down
38 changes: 26 additions & 12 deletions signac/contrib/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,12 @@ def ws(self):
return self.workspace()

def reset_statepoint(self, new_statepoint):
"""Reset the state point of this job.
"""Overwrite the state point of this job while preserving job data.

This method will change the job id if the state point has been altered.

For more information, see
`Modifying the State Point <https://docs.signac.io/en/latest/jobs.html#modifying-the-state-point>`_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use an intersphinx reference to _project-job-statepoint-modify.

See this guide: https://github.com/glotzerlab/signac-docs/wiki/How-to-cross-reference-links-between-package-docs-and-signac-docs-using-intersphinx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make a new issue to add intersphinx because none of the files use it yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made #452 to involve newer contributors


.. danger::

Expand All @@ -203,7 +208,7 @@ def reset_statepoint(self, new_statepoint):
new_statepoint : dict
The job's new state point.

"""
""" # noqa: E501
dst = self._project.open_job(new_statepoint)
if dst == self:
return
Expand Down Expand Up @@ -249,7 +254,15 @@ def _reset_sp(self, new_statepoint=None):
self.reset_statepoint(new_statepoint)

def update_statepoint(self, update, overwrite=False):
"""Update the state point of this job.
"""Change the state point of this job while preserving job data.

By default, this method will not change existing parameters of the
state point of the job.

This method will change the job id if the state point has been altered.

For more information, see
`Modifying the State Point <https://docs.signac.io/en/latest/jobs.html#modifying-the-state-point>`_.
cbkerr marked this conversation as resolved.
Show resolved Hide resolved

.. warning::

Expand All @@ -261,22 +274,23 @@ def update_statepoint(self, update, overwrite=False):
----------
update : dict
A mapping used for the state point update.
overwrite :
Set to true, to ignore whether this update overwrites parameters,
which are currently part of the job's state point.
Use with caution! (Default value = False)
overwrite : bool, optional
If True, this method will set all existing and new parameters
to a job's statepoint, making it equivalent to
:meth:`~.reset_statepoint`. Use with caution!
(Default value = False).

Raises
------
KeyError
If the update contains keys, which are already part of the job's
state point and overwrite is False.
DestinationExistsError
:class:`~signac.errors.DestinationExistsError`
If a job associated with the new state point is already initialized.
OSError
If the move failed due to an unknown system related error.

"""
""" # noqa: E501
statepoint = self.statepoint()
if not overwrite:
for key, value in update.items():
Expand All @@ -295,7 +309,7 @@ def _read_manifest(self):

Raises
------
JobsCorruptedError
:class:`~signac.errors.JobsCorruptedError`
If an error occurs while parsing the state point manifest.
OSError
If an error occurs while reading the state point manifest.
Expand Down Expand Up @@ -567,7 +581,7 @@ def _check_manifest(self):

Raises
------
JobsCorruptedError
:class:`~signac.errors.JobsCorruptedError`
If the manifest hash is not equal to the job id.

"""
Expand Down Expand Up @@ -743,7 +757,7 @@ def sync(self, other, strategy=None, exclude=None, doc_sync=None, **kwargs):

Raises
------
FileSyncConflict
:class:`~signac.errors.FileSyncConflict`
In case that a file synchronization results in a conflict.

"""
Expand Down
26 changes: 17 additions & 9 deletions signac/contrib/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,7 @@ def _get_statepoint(self, job_id, fn=None):
------
KeyError
If the state point associated with job_id could not be found.
JobsCorruptedError
:class:`signac.errors.JobsCorruptedError`
If the state point manifest file corresponding to job_id is
inaccessible or corrupted.

Expand Down Expand Up @@ -1346,7 +1346,7 @@ def get_statepoint(self, jobid, fn=None):
------
KeyError
If the state point associated with jobid could not be found.
JobsCorruptedError
:class:`signac.errors.JobsCorruptedError`
If the state point manifest file corresponding to jobid is
inaccessible or corrupted.

Expand Down Expand Up @@ -1430,7 +1430,9 @@ def create_linked_view(self, prefix=None, job_ids=None, index=None, path=None):
details="Use job.reset_statepoint() instead.",
)
def reset_statepoint(self, job, new_statepoint):
"""Reset the state point of job.
"""Overwrite the state point of this job while preserving job data.

This method will change the job id if the state point has been altered.

.. danger::

Expand Down Expand Up @@ -1462,7 +1464,12 @@ def reset_statepoint(self, job, new_statepoint):
details="Use job.update_statepoint() instead.",
)
def update_statepoint(self, job, update, overwrite=False):
"""Update the state point of this job.
"""Change the state point of this job while preserving job data.

By default, this method will not change existing parameters of the
state point of the job.

This method will change the job id if the state point has been altered.

.. warning::

Expand All @@ -1476,9 +1483,10 @@ def update_statepoint(self, job, update, overwrite=False):
The job whose state point shall be updated.
update : mapping
A mapping used for the state point update.
overwrite :
Set to true to ignore whether this update overwrites parameters,
which are currently part of the job's state point. Use with caution!
overwrite : bool, optional
If True, this method will set all existing and new parameters
to a job's statepoint, making it equivalent to
:meth:`~.reset_statepoint`. Use with caution!
(Default value = False).

Raises
Expand Down Expand Up @@ -1745,7 +1753,7 @@ def check(self):

Raises
------
JobsCorruptedError
:class:`signac.errors.JobsCorruptedError`
When one or more jobs are identified as corrupted.

"""
Expand Down Expand Up @@ -1785,7 +1793,7 @@ def repair(self, fn_statepoints=None, index=None, job_ids=None):

Raises
------
JobsCorruptedError
:class:`signac.errors.JobsCorruptedError`
When one or more corrupted job could not be repaired.

"""
Expand Down
20 changes: 12 additions & 8 deletions signac/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
DestinationExistsError,
IncompatibleSchemaVersion,
JobsCorruptedError,
StatepointParsingError,
WorkspaceError,
)
from .core.errors import Error
from .core.jsondict import BufferedFileError, BufferException
Expand Down Expand Up @@ -65,19 +67,21 @@ class KeyTypeError(TypeError):


__all__ = [
"Error",
"AuthenticationError",
"BufferException",
"BufferedFileError",
"ConfigError",
"AuthenticationError",
"DestinationExistsError",
"DocumentSyncConflict",
"Error",
"ExportError",
"FetchError",
"DestinationExistsError",
"JobsCorruptedError",
"IncompatibleSchemaVersion",
"SyncConflict",
"FileSyncConflict",
"DocumentSyncConflict",
"SchemaSyncConflict",
"IncompatibleSchemaVersion",
"InvalidKeyError",
"JobsCorruptedError",
"SchemaSyncConflict",
"StatepointParsingError",
"SyncConflict",
"WorkspaceError",
]
6 changes: 3 additions & 3 deletions signac/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,14 @@ def sync_projects(

Raises
------
DocumentSyncConflict
:class:`~signac.errors.DocumentSyncConflict`
If there are conflicting keys within the project or job documents that
cannot be resolved with the given strategy or if there is no strategy
provided.
FileSyncConflict
:class:`~signac.errors.FileSyncConflict`
If there are differing files that cannot be resolved with the given
strategy or if no strategy is provided.
SchemaSyncConflict
:class:`~signac.errors.SchemaSyncConflict`
In case that the check_schema argument is True and the detected state
point schema of this and the other project differ.

Expand Down