Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into additional_deprecat…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
vyasr committed Mar 5, 2022
2 parents de2da7a + 2c6da9f commit d4a347a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 37 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Changed
+++++++

- Schema migration is now performed on directories rather than signac projects and supports a wider range of schemas (#654).
- Deprecated features now use ``FutureWarning`` instead of ``DeprecationWarning``, which is hidden by default (#687, #691).

Deprecated
++++++++++
Expand All @@ -31,6 +32,11 @@ Deprecated
- ``signac.cite`` module is deprecated (#611, #592).
- ``config.get_config`` method is deprecated (#675).

Changed
+++++++

- Project names have a default in anticipation of removing names entirely. Project names will be removed in signac 2.0.

Fixed
+++++

Expand Down
4 changes: 4 additions & 0 deletions contributors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,8 @@ contributors:
family-names: Dave
given-names: Shantanu
affiliation: "Jodhpur Institute of Engineering and Technology"
-
family-names: Mahapatra
given-names: Onkar
affiliation: "Cluster Innovation Centre, New Delhi"
...
8 changes: 4 additions & 4 deletions requirements/requirements-benchmark.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
click==8.0.3
click==8.0.4
gitdb2==4.0.2
GitPython==3.1.26
numpy==1.22.1
pandas==1.4.0; implementation_name=='cpython' --no-binary :none:
GitPython==3.1.27
numpy==1.22.2
pandas==1.4.1; implementation_name=='cpython' --no-binary :none:
psutil==5.9.0
8 changes: 4 additions & 4 deletions requirements/requirements-test-optional.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
h5py==3.6.0; implementation_name=='cpython'
numpy==1.22.1
pandas==1.4.0; implementation_name=='cpython'
numpy==1.22.2
pandas==1.4.1; implementation_name=='cpython'
pymongo==4.0.1; implementation_name=='cpython'
redis==4.1.2
ruamel.yaml==0.17.20
redis==4.1.4
ruamel.yaml==0.17.21
tables==3.7.0; implementation_name=='cpython'
zarr==2.10.3; platform_system!='Windows'
4 changes: 2 additions & 2 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
coverage==6.3
pytest==6.2.5
coverage==6.3.2
pytest==7.0.1
pytest-cov==3.0.0
10 changes: 5 additions & 5 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1093,10 +1093,7 @@ def main_shell(args):
except LookupError:
print("signac", __version__)
print("No project within this directory.")
print(
"If you want to initialize a project, execute `$ signac init <project-name>`, "
"where <project-name> can be freely chosen."
)
print("If you want to initialize a project, execute `$ signac init`.")
else:
_jobs = find_with_filter(args)

Expand Down Expand Up @@ -1201,7 +1198,10 @@ def main():

parser_init = subparsers.add_parser("init")
parser_init.add_argument(
"project_id", type=str, help="Initialize a project with the given project id."
"project_id",
nargs="?",
type=str,
help="Initialize a project with the given project id.",
)
parser_init.add_argument(
"-w",
Expand Down
55 changes: 34 additions & 21 deletions signac/contrib/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ def get_indexes(root):
"information."
)

# Temporary default for project names until they are removed entirely in signac 2.0
_DEFAULT_PROJECT_NAME = None


class JobSearchIndex:
"""Search for specific jobs with filters.
Expand Down Expand Up @@ -170,7 +173,7 @@ def find_job_ids(self, filter=None, doc_filter=None):
if doc_filter:
filter.update(doc_filter)
elif doc_filter:
warnings.warn(DOC_FILTER_WARNING, DeprecationWarning)
warnings.warn(DOC_FILTER_WARNING, FutureWarning)
filter = doc_filter
return self._collection._find(filter)

Expand Down Expand Up @@ -917,7 +920,7 @@ def detect_schema(self, exclude_const=False, subset=None, index=None):
if index is None:
index = self.index(include_job_document=False)
else:
warnings.warn(INDEX_DEPRECATION_WARNING, DeprecationWarning)
warnings.warn(INDEX_DEPRECATION_WARNING, FutureWarning)
if subset is not None:
subset = {str(s) for s in subset}
index = [doc for doc in index if doc["_id"] in subset]
Expand Down Expand Up @@ -1031,15 +1034,15 @@ def _find_job_ids(self, filter=None, doc_filter=None, index=None):
if index is None:
filter = dict(parse_filter(_add_prefix("sp.", filter)))
if doc_filter:
warnings.warn(DOC_FILTER_WARNING, DeprecationWarning)
warnings.warn(DOC_FILTER_WARNING, FutureWarning)
filter.update(parse_filter(_add_prefix("doc.", doc_filter)))
index = self.index(include_job_document=True)
elif "doc" in _root_keys(filter):
index = self.index(include_job_document=True)
else:
index = self._sp_index()
else:
warnings.warn(INDEX_DEPRECATION_WARNING, DeprecationWarning)
warnings.warn(INDEX_DEPRECATION_WARNING, FutureWarning)

return Collection(index, _trust=True)._find(filter)

Expand Down Expand Up @@ -1079,7 +1082,7 @@ def find_jobs(self, filter=None, doc_filter=None):
"""
filter = dict(parse_filter(_add_prefix("sp.", filter)))
if doc_filter:
warnings.warn(DOC_FILTER_WARNING, DeprecationWarning)
warnings.warn(DOC_FILTER_WARNING, FutureWarning)
filter.update(parse_filter(_add_prefix("doc.", doc_filter)))
return JobsCursor(self, filter)

Expand Down Expand Up @@ -1521,7 +1524,7 @@ def create_linked_view(self, prefix=None, job_ids=None, index=None, path=None):
"""
if index is not None:
warnings.warn(INDEX_DEPRECATION_WARNING, DeprecationWarning)
warnings.warn(INDEX_DEPRECATION_WARNING, FutureWarning)
from .linked_view import create_linked_view

return create_linked_view(self, prefix, job_ids, index, path)
Expand Down Expand Up @@ -1922,7 +1925,7 @@ def repair(self, fn_statepoints=None, index=None, job_ids=None):
if index is not None:
for doc in index:
self._sp_cache[doc["signac_id"]] = doc["sp"]
warnings.warn(INDEX_DEPRECATION_WARNING, DeprecationWarning)
warnings.warn(INDEX_DEPRECATION_WARNING, FutureWarning)
corrupted = []
for job_id in job_ids:
try:
Expand Down Expand Up @@ -2226,7 +2229,7 @@ def create_access_module(self, filename=None, main=True, master=None):
"""
if master is not None:
warnings.warn(
"The parameter master has been renamed to main.", DeprecationWarning
"The parameter master has been renamed to main.", FutureWarning
)
main = master

Expand Down Expand Up @@ -2282,8 +2285,8 @@ def temporary_project(self, name=None, dir=None):
yield tmp_project

@classmethod
def init_project(cls, name, root=None, workspace=None, make_dir=True):
"""Initialize a project with the given name.
def init_project(cls, name=None, root=None, workspace=None, make_dir=True):
"""Initialize a project.
It is safe to call this function multiple times with the same
arguments. However, a `RuntimeError` is raised if an existing project
Expand All @@ -2294,15 +2297,15 @@ def init_project(cls, name, root=None, workspace=None, make_dir=True):
Parameters
----------
name : str
The name of the project to initialize.
root : str
name : str, optional
The name of the project to initialize (Default value = None).
root : str, optional
The root directory for the project.
Defaults to the current working directory.
workspace : str
workspace : str, optional
The workspace directory for the project.
Defaults to a subdirectory ``workspace`` in the project root.
make_dir : bool
make_dir : bool, optional
Create the project root directory if it does not exist yet
(Default value = True).
Expand All @@ -2320,6 +2323,16 @@ def init_project(cls, name, root=None, workspace=None, make_dir=True):
"""
if root is None:
root = os.getcwd()

if name is not None:
warnings.warn(
"Project names are deprecated and will be removed in signac 2.0 in favor of using "
"the project root directory to identify projects. The name argument to "
"init_project should be removed.",
FutureWarning,
)
else:
name = _DEFAULT_PROJECT_NAME
try:
project = cls.get_project(root=root, search=False)
except LookupError:
Expand Down Expand Up @@ -3033,24 +3046,24 @@ def _repr_html_(self):
return repr(self) + self._repr_html_jobs()


def init_project(name, root=None, workspace=None, make_dir=True):
"""Initialize a project with the given name.
def init_project(name=None, root=None, workspace=None, make_dir=True):
"""Initialize a project.
It is safe to call this function multiple times with the same arguments.
However, a `RuntimeError` is raised if an existing project configuration
would conflict with the provided initialization parameters.
Parameters
----------
name : str
name : str, optional
The name of the project to initialize.
root : str
root : str, optional
The root directory for the project.
Defaults to the current working directory.
workspace : str
workspace : str, optional
The workspace directory for the project.
Defaults to a subdirectory ``workspace`` in the project root.
make_dir : bool
make_dir : bool, optional
Create the project root directory, if it does not exist yet (Default
value = True).
Expand Down
2 changes: 1 addition & 1 deletion signac/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def diff_jobs(*jobs):
Examples
--------
>>> import signac
>>> project = signac.init_project('project_name')
>>> project = signac.init_project()
>>> job1 = project.open_job({'constant': 42, 'diff1': 0, 'diff2': 1}).init()
>>> job2 = project.open_job({'constant': 42, 'diff1': 1, 'diff2': 1}).init()
>>> job3 = project.open_job({'constant': 42, 'diff1': 2, 'diff2': 2}).init()
Expand Down

0 comments on commit d4a347a

Please sign in to comment.