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

Additional deprecations #685

Merged
merged 29 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
dace571
Remove some unnecessary code in project.py.
vyasr Feb 21, 2022
a530fef
Make notes on possible deprecations/changes in job.py.
vyasr Feb 21, 2022
102ef00
Replace all DeprecationWarnings with FutureWarnings.
vyasr Feb 21, 2022
bb454b4
Deprecate or makes on potentially unnecessary schema APIs.
vyasr Feb 21, 2022
5eea5e1
Deprecate unnecessary utility module.
vyasr Feb 21, 2022
31d4267
Some notes.
vyasr Feb 21, 2022
b26d832
Revert "Replace all DeprecationWarnings with FutureWarnings."
vyasr Feb 21, 2022
4f98865
Update comment.
vyasr Feb 21, 2022
5f61c44
Minor fixes.
vyasr Feb 21, 2022
3d14baf
Add new path properties and deprecate Project.root_directory, Job.ws,…
vyasr Mar 5, 2022
2ea0616
Deprecate Job.reset_statepoint.
vyasr Mar 5, 2022
52b606f
Add version guards for deprecated functionality.
vyasr Mar 5, 2022
a741d0d
Deprecate ProjectSchema.detect.
vyasr Mar 5, 2022
2266f77
Deprecate ProjectSchema.__call__.
vyasr Mar 5, 2022
de2da7a
Address various minor comments.
vyasr Mar 5, 2022
d4a347a
Merge remote-tracking branch 'origin/master' into additional_deprecat…
vyasr Mar 5, 2022
09dc775
Address most PR comments.
vyasr Mar 6, 2022
57b7390
Add the --path parameter and deprecate --workspace.
vyasr Mar 6, 2022
2cf344a
Address PR comments.
vyasr Mar 13, 2022
e89c1be
Merge remote-tracking branch 'origin/master' into additional_deprecat…
vyasr Mar 13, 2022
76770a3
Correctly update internal variable.
vyasr Mar 14, 2022
adc4e65
Address PR comments.
vyasr Mar 19, 2022
85bf881
Merge branch 'master' into additional_deprecations
bdice Mar 28, 2022
8e28bb1
Merge remote-tracking branch 'origin/master' into additional_deprecat…
vyasr Apr 2, 2022
0d84123
PR comments.
vyasr Apr 2, 2022
0effd92
Fix deprecation import.
vyasr Apr 2, 2022
d146952
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 2, 2022
692f181
Merge remote-tracking branch 'origin/master' into additional_deprecat…
vyasr Apr 12, 2022
4e9c777
Remove cached_property TODOs.
vyasr Apr 12, 2022
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
19 changes: 16 additions & 3 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def main_project(args):
print(json.dumps(doc))
return
if args.workspace:
print(project.workspace())
print(project.workspace)
vyasr marked this conversation as resolved.
Show resolved Hide resolved
else:
print(project)

Expand All @@ -279,6 +279,13 @@ def main_job(args):
if args.create:
job.init()
if args.workspace:
warnings.warn(
"The `-w/--workspace` parameter is deprecated as of version 1.8 and will be removed in "
"version 2.0. Use -p/--path instead",
FutureWarning,
)
args.path = True
if args.path:
print(job.workspace())
else:
print(job)
Expand Down Expand Up @@ -658,7 +665,7 @@ def _main_import_interactive(project, origin, args):
project_id=project.get_id(),
job_banner="",
root_path=project.root_directory(),
workspace_path=project.workspace(),
workspace_path=project.workspace,
size=len(project),
origin=args.origin,
),
Expand Down Expand Up @@ -1169,7 +1176,7 @@ def write_history_file():
project_id=project.id,
job_banner=f"\nJob:\t\t{job.id}" if job is not None else "",
root_path=project.root_directory(),
workspace_path=project.workspace(),
workspace_path=project.workspace,
size=len(project),
),
)
Expand Down Expand Up @@ -1244,6 +1251,12 @@ def main():
action="store_true",
help="Print the job's workspace path instead of the job id.",
)
parser_job.add_argument(
"-p",
"--path",
action="store_true",
help="Print the job's path instead of the job id.",
)
parser_job.add_argument(
"-c",
"--create",
Expand Down
5 changes: 5 additions & 0 deletions signac/cite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

from .version import __version__

"""
THIS MODULE IS DEPRECATED!
"""


ARXIV_BIBTEX = """@online{signac,
author = {Carl S. Adorf and Paul M. Dodd and Sharon C. Glotzer},
title = {signac - A Simple Data Management Framework},
Expand Down
2 changes: 1 addition & 1 deletion signac/contrib/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def _crawl_directory_data_space(root, project, schema_function):

"""
# We compare paths to the 'realpath' of the project workspace to catch loops.
workspace_real_path = os.path.realpath(project.workspace())
workspace_real_path = os.path.realpath(project.workspace)

for path, dirs, _ in os.walk(root):
sp = schema_function(path)
Expand Down
2 changes: 1 addition & 1 deletion signac/contrib/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class SignacProjectCrawler(RegexFileCrawler):
def __init__(self, root):
from .project import get_project

root = get_project(root=root).workspace()
root = get_project(root=root).workspace
self._statepoints = {}
return super().__init__(root=root)

Expand Down
80 changes: 56 additions & 24 deletions signac/contrib/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _save(self):
# Move the state point to an intermediate location as a backup.
os.replace(self.filename, tmp_statepoint_file)
try:
new_workspace = os.path.join(job._project.workspace(), new_id)
new_workspace = os.path.join(job._project.workspace, new_id)
os.replace(job.workspace(), new_workspace)
except OSError as error:
os.replace(tmp_statepoint_file, self.filename) # rollback
Expand Down Expand Up @@ -281,8 +281,11 @@ def __init__(self, project, statepoint=None, _id=None):

def _initialize_lazy_properties(self):
"""Initialize all properties that are designed to be loaded lazily."""
# TODO: Consider using functools.cached_property for these instead. That simplify our code,
# although at the expense of creating multiple locks (each cached_property has its own lock
# AFAICT from looking at the implementation).
with self._lock:
self._wd = None
self._path = None
self._document = None
self._stores = None
self._cwd = []
Expand Down Expand Up @@ -335,22 +338,15 @@ def __repr__(self):
self.__class__.__name__, repr(self._project), self.statepoint
)

@deprecated(
deprecated_in="1.8",
removed_in="2.0",
current_version=__version__,
details="Use Job.path instead.",
)
def workspace(self):
vyasr marked this conversation as resolved.
Show resolved Hide resolved
"""Return the job's unique workspace directory.

See :ref:`signac job -w <signac-cli-job>` for the command line equivalent.

Returns
-------
str
The path to the job's workspace directory.

"""
if self._wd is None:
# We can rely on the project workspace to be well-formed, so just
# use str.join with os.sep instead of os.path.join for speed.
self._wd = os.sep.join((self._project.workspace(), self.id))
return self._wd
"""Alias for :attr:`~Job.path`."""
return self.path

@property
def _statepoint_filename(self):
Expand All @@ -359,11 +355,37 @@ def _statepoint_filename(self):
# use str.join with os.sep instead of os.path.join for speed.
return os.sep.join((self.workspace(), self.FN_MANIFEST))

@property
# Tell mypy to ignore type checking of the decorator because decorated
# properties aren't supported: https://github.com/python/mypy/issues/1362
@property # type: ignore
vyasr marked this conversation as resolved.
Show resolved Hide resolved
@deprecated(
deprecated_in="1.8",
removed_in="2.0",
current_version=__version__,
details="Use Job.path instead.",
)
def ws(self):
"""Alias for :meth:`~Job.workspace`."""
return self.workspace()
"""Alias for :attr:`~Job.path`."""
return self.path

@property
def path(self):
"""str: The path to the job directory.

See :ref:`signac job -w <signac-cli-job>` for the command line equivalent.
vyasr marked this conversation as resolved.
Show resolved Hide resolved
"""
if self._path is None:
# We can rely on the project workspace to be well-formed, so just
# use str.join with os.sep instead of os.path.join for speed.
self._path = os.sep.join((self._project.workspace, self.id))
return self._path

@deprecated(
deprecated_in="1.8",
removed_in="2.0",
current_version=__version__,
details="Use job.statepoint = new_statepoint instead.",
)
def reset_statepoint(self, new_statepoint):
"""Overwrite the state point of this job while preserving job data.

Expand Down Expand Up @@ -448,7 +470,13 @@ def update_statepoint(self, update, overwrite=False):

@property
def statepoint(self):
"""Get the job's state point.
"""Get or set the job's state point.

Setting the state point to a different value will change the job id.

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

.. warning::

Expand All @@ -463,11 +491,16 @@ def statepoint(self):

See :ref:`signac statepoint <signac-cli-statepoint>` for the command line equivalent.

.. danger::

Use this function with caution! Resetting a job's state point
may sometimes be necessary, but can possibly lead to incoherent
data spaces.

Returns
-------
dict
Returns the job's state point.

"""
with self._lock:
if self._statepoint_requires_init:
Expand All @@ -491,7 +524,6 @@ def statepoint(self, new_statepoint):
----------
new_statepoint : dict
The new state point to be assigned.

"""
self.reset_statepoint(new_statepoint)

Expand Down Expand Up @@ -785,7 +817,7 @@ def move(self, project):
with self._lock:
statepoint = self.statepoint()
dst = project.open_job(statepoint)
_mkdir_p(project.workspace())
_mkdir_p(project.workspace)
try:
os.replace(self.workspace(), dst.workspace())
except OSError as error:
Expand Down
Loading