Skip to content

Commit

Permalink
Remove compatibility layers and other deprecated code (#752)
Browse files Browse the repository at this point in the history
* Remove doc filter support.

* Remove support for workspace as function.

* Remove backwards compatibility layer for project_names in init.

* Remove backwards compat layers for schema.

* Remove backwards compat layers in CLI.

* Get all tests passing.

* Fix style.

* Update changelog.

* Update changelog.

* Address all PR comments except for renaming init_project parameter.
  • Loading branch information
vyasr authored May 6, 2022
1 parent 12bbf12 commit cfa1e2c
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 503 deletions.
12 changes: 8 additions & 4 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Removed
- The pre-SyncedCollection synchronized dictionary classes, including SyncedDict, SyncedAttrDict, and JSONDict (#577).
- The old custom JSON encoder and dumps wrapper (#577).
- The MPIPool and the filesystems.py module (#575).
- The following Project methods: ``get_id``, ``build_job_search_index``, ``build_job_statepoint_index``, ``find_job_ids``, ``reset_statepoint``, ``update_statepoint``, ``create_access_module``, ``index``, ``dump_statepoints``, ``get_statepoint``, ``read_statepoints``, ``write_statepoints``, ``groupbydoc`` (#574, #593, #599, #601).
- The following Job methods: ``get_id`` (#578).
- The following Project methods: ``get_id``, ``build_job_search_index``, ``build_job_statepoint_index``, ``find_job_ids``, ``reset_statepoint``, ``update_statepoint``, ``create_access_module``, ``index``, ``dump_statepoints``, ``get_statepoint``, ``read_statepoints``, ``write_statepoints``, ``groupbydoc``, ``root_directory``, ``num_jobs`` (#574, #593, #599, #601, #752).
- The following Job methods: ``get_id``, ``workspace``, ``ws``, ``reset_statepoint`` (#578, #752).
- The ``syncutil.copytree`` method (#581).
- All Crawlers, including ``RegexFileCrawler``, ``MainCrawler``, ``MasterCrawler``, ``SignacProjectCrawler``, and ``BaseCrawler``, in addition to all associated functionality in indexing.py (#580).
- The cite.py module (#594).
Expand All @@ -40,9 +40,13 @@ Removed
- The ability to pass indexes to various ``Project`` methods (#599).
- The following ``JobsCursor`` methods: ``groupbydoc``, ``next`` (#601, #604).
- The ``Project.config`` property is no longer mutable. Use the command line ``$ signac config`` to modify configuration (#608, #246, #244).
- The following config related functions: ``get_config_file``, ``search_standard_dirs`` (#674).
- The following config related functions: ``get_config``, ``search_standard_dirs`` (#674).
- ``Project`` subclasses can no longer define a ``Job`` subclass to use (#588, #693).
- The ``Collection`` class has been removed (#664, #667, #683).
- The ``Collection`` class (#664, #667, #683).
- The ``project`` CLI subcommand (#752).
- The ``--workspace`` option for the command line ``job`` subcommand (#752).
- The ability to call ``Project.workspace``, it is strictly a property now (#752).
- ``ProjectSchema.__call__``, ``ProjectSchema.detect`` (#752).

Version 1
=========
Expand Down
37 changes: 3 additions & 34 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,6 @@ def find_with_filter(args):
return project._find_job_ids(filter=filter_)


def main_project(args):
"""Handle project subcommand."""
warnings.warn(
"The `project` command is deprecated as of version 1.8 and will be removed in "
"version 2.0.",
FutureWarning,
)
project = get_project()
if args.workspace:
print(project.workspace)
else:
print(project)


def main_job(args):
"""Handle job subcommand."""
project = get_project()
Expand All @@ -190,13 +176,6 @@ def main_job(args):
job = project.open_job(statepoint)
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.path)
else:
Expand Down Expand Up @@ -354,7 +333,7 @@ def main_view(args):

def main_init(args):
"""Handle init subcommand."""
init_project(name=args.project_id, root=os.getcwd())
init_project(root=os.getcwd())
_print_err("Initialized project.")


Expand Down Expand Up @@ -550,7 +529,7 @@ def _main_import_interactive(project, origin, args):
python_version=sys.version,
signac_version=__version__,
job_banner="",
root_path=project.root_directory(),
root_path=project.path,
size=len(project),
origin=args.origin,
),
Expand Down Expand Up @@ -891,7 +870,7 @@ def write_history_file():
python_version=sys.version,
signac_version=__version__,
job_banner=f"\nJob:\t\t{job.id}" if job is not None else "",
root_path=project.root_directory(),
root_path=project.path,
size=len(project),
),
)
Expand Down Expand Up @@ -919,18 +898,8 @@ def main():
subparsers = parser.add_subparsers()

parser_init = subparsers.add_parser("init")
parser_init.add_argument("project_id", nargs="?", help=argparse.SUPPRESS)
parser_init.set_defaults(func=main_init)

parser_project = subparsers.add_parser("project")
parser_project.add_argument(
"-w",
"--workspace",
action="store_true",
help="Print the project's workspace path instead of the project id.",
)
parser_project.set_defaults(func=main_project)

parser_job = subparsers.add_parser("job")
parser_job.add_argument(
"statepoint",
Expand Down
78 changes: 12 additions & 66 deletions signac/contrib/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from threading import RLock
from typing import FrozenSet

from ..common.deprecation import deprecated
from ..core.h5store import H5StoreManager
from ..sync import sync_jobs
from ..synced_collections.backends.collection_json import (
Expand All @@ -21,7 +20,6 @@
json_attr_dict_validator,
)
from ..synced_collections.errors import KeyTypeError
from ..version import __version__
from .errors import DestinationExistsError, JobsCorruptedError
from .hashing import calc_id
from .utility import _mkdir_p
Expand Down Expand Up @@ -317,16 +315,6 @@ 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):
"""Alias for :attr:`~Job.path`."""
return self.path

@property
def _statepoint_filename(self):
"""Get the path of the state point file for this job."""
Expand All @@ -335,19 +323,6 @@ def _statepoint_filename(self):
# instead of os.path.join for speed.
return os.sep.join((self.path, self.FN_STATE_POINT))

# 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
@deprecated(
deprecated_in="1.8",
removed_in="2.0",
current_version=__version__,
details="Use Job.path instead.",
)
def ws(self):
"""Alias for :attr:`~Job.path`."""
return self.path

@property
def path(self):
"""str: The path to the job directory.
Expand All @@ -360,45 +335,6 @@ def path(self):
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.
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>`_.
.. danger::
Use this function with caution! Resetting a job's state point
may sometimes be necessary, but can possibly lead to incoherent
data spaces.
Parameters
----------
new_statepoint : dict
The job's new state point.
"""
with self._lock:
if self._statepoint_requires_init:
# Instantiate state point data lazily - no load is required, since
# we are provided with the new state point data.
self._statepoint = _StatePointDict(
jobs=[self], filename=self._statepoint_filename
)
self._statepoint_requires_init = False
self.statepoint.reset(new_statepoint)

self._project._register(self.id, new_statepoint)

def update_statepoint(self, update, overwrite=False):
"""Change the state point of this job while preserving job data.
Expand Down Expand Up @@ -446,7 +382,7 @@ def update_statepoint(self, update, overwrite=False):
"mapping with another value."
)
statepoint.update(update)
self.reset_statepoint(statepoint)
self.statepoint = statepoint

@property
def statepoint(self):
Expand Down Expand Up @@ -505,7 +441,17 @@ def statepoint(self, new_statepoint):
new_statepoint : dict
The new state point to be assigned.
"""
self.reset_statepoint(new_statepoint)
with self._lock:
if self._statepoint_requires_init:
# Instantiate state point data lazily - no load is required, since
# we are provided with the new state point data.
self._statepoint = _StatePointDict(
jobs=[self], filename=self._statepoint_filename
)
self._statepoint_requires_init = False
self.statepoint.reset(new_statepoint)

self._project._register(self.id, new_statepoint)

@property
def sp(self):
Expand Down
Loading

0 comments on commit cfa1e2c

Please sign in to comment.