Skip to content

Commit

Permalink
Merge branch 'master' into github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice authored Jan 17, 2023
2 parents 717ee75 + 7e36f5c commit d31c9d7
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 190 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ exclude: '(?:^flow/util/mistune/)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.3.0'
rev: 'v4.4.0'
hooks:
- id: end-of-file-fixer
exclude: 'setup.cfg'
- id: trailing-whitespace
exclude: 'setup.cfg'
- id: debug-statements
- repo: https://github.com/asottile/pyupgrade
rev: 'v2.38.2'
rev: 'v3.3.1'
hooks:
- id: pyupgrade
args:
- --py38-plus
- repo: https://github.com/PyCQA/isort
rev: '5.10.1'
rev: '5.11.4'
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: '22.8.0'
rev: '22.12.0'
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: '5.0.4'
rev: '6.0.0'
hooks:
- id: flake8
- repo: https://github.com/PyCQA/pydocstyle
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@
},
"title": "signac-flow",
"upload_type": "software",
"version": "0.22.0"
"version": "0.23.0"
}
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
---
cff-version: "1.0.3"
title: signac-flow
version: 0.22.0
version: 0.23.0
abstract: |
The signac-flow tool provides the basic components to set up simple to complex workflows for projects as part of the signac framework. That includes the definition of data pipelines, execution of data space operations and the submission of operations to high-performance super computers.
authors:
Expand Down
34 changes: 28 additions & 6 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,62 @@ Changelog
The **signac-flow** package follows `semantic versioning <https://semver.org/>`_.
The numbers in brackets denote the related GitHub issue and/or pull request.

Version 0.24
============

[0.24.0] -- 20xx-xx-xx
----------------------

Changed
+++++++

- Placing ``@FlowProject.pre`` and ``@FlowProject.post`` before the ``FlowProject.operation`` decorator raises an error (#700).
- Updated CI to use GitHub Actions (#698).

Removed
+++++++

- ``@flow.aggregates.aggregator()`` use ``FlowProject.operation(aggregator=...)`` instead (#700).
- ``alias`` CLI argument to ``flow init`` (#700).
- ``FlowGroupEntry.with_directives`` use directives keyword argument in ``FlowGroupEntry()``(#700).

Version 0.23
============

[0.23.0] -- 20xx-xx-xx
[0.23.0] -- 2022-12-09
----------------------

Added
+++++

- Add official support for Python version 3.11 (#697).
- Official Python 3.11 support (#697).
- The ``flow.FlowProject.operation`` decorator now has an ``aggregator`` keyword argument: ``@FlowProject.operation(aggregator=aggregator.groupsof(2))`` (#681).
- The ``FlowGroupEntry`` class can be called with a ``directives`` keyword argument: ``FlowGroupEntry(directives={...})`` (#696).

Changed
+++++++

- Deprecated using ``flow.aggregates.aggregator`` as a decorator.
- Deprecated placing ``@FlowProject.pre`` and ``@FlowProject.post`` before the ``FlowProject.operation`` decorator (#690).
- Require ``signac`` version 1.8.0 (#693).
- Deprecated ``alias`` CLI argument to ``flow init`` (#693).
- Algorithm for computing cluster job ids (#695).
- Updated CI to use GitHub Actions (#698).
- Deprecated ``FlowGroupEntry.with_directives`` in favor of a directives keyword argument in ``FlowGroupEntry()``(#696).

Fixed
+++++

- Detecting correct environment on Delta GPU nodes (#682).
- Identical aggregates are used only once in submission and running (#694).
- Identical aggregates are used only once in submission and running (#694, #688).

Removed
+++++++

- ``show_traceback`` from CLI and config (#690).
- Formatting the output of a ``FlowCmdOperation`` (#686).
- ``@flow.cmd`` and ``flow.with_job`` (#686).
- ``@flow.cmd`` and ``flow.with_job`` (#686, #669).
- ``@FlowProject.operation.with_directives`` (#686).
- The ``flow.testing`` module (#691).
- The ``flow.testing`` module (#691, #692).

Version 0.22
============
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def __getattr__(cls, name):
# built documents.
#
# The short X.Y version.
version = "0.22.0"
version = "0.23.0"
# The full version, including alpha/beta/rc tags.
release = "0.22.0"
release = "0.23.0"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
15 changes: 0 additions & 15 deletions flow/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from signac import get_project, init_project

from . import __version__, environment, template
from .util.misc import _deprecated_warning

logger = logging.getLogger(__name__)

Expand All @@ -32,13 +31,6 @@ def main_init(args):
try:
get_project()
except LookupError:
if args.alias != "":
_deprecated_warning(
deprecation="alias",
alternative="",
deprecated_in="0.23.0",
removed_in="0.24.0",
)
init_project()
print("Initialized signac project in current directory.", file=sys.stderr)
try:
Expand Down Expand Up @@ -115,13 +107,6 @@ def main():
"init", help="Initialize a signac-flow project."
)
parser_init.set_defaults(func=main_init)
parser_init.add_argument(
"alias",
type=str,
nargs="?",
default="",
help="Unused, will be removed in flow 0.24.0.",
)
parser_init.add_argument(
"-t",
"--template",
Expand Down
37 changes: 0 additions & 37 deletions flow/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
from collections.abc import Collection, Iterable, Mapping
from hashlib import md5

from .errors import FlowProjectDefinitionError
from .util.misc import _deprecated_warning


def _get_unique_function_id(func):
"""Generate unique id for the provided function.
Expand Down Expand Up @@ -335,40 +332,6 @@ def _create_AggregateStore(self, project):
else:
return _AggregateStore(self, project)

def __call__(self, func=None):
"""Add this aggregator to a provided operation.
This call operator allows the class to be used as a decorator.
Parameters
----------
func : callable
The function to decorate.
"""
_deprecated_warning(
deprecation="@aggregator(...)",
alternative="Use FlowProject.operation(aggregator=aggregator(...)) instead.",
deprecated_in="0.23.0",
removed_in="0.24.0",
)
if not callable(func):
raise FlowProjectDefinitionError(
"Invalid argument passed while calling the aggregate "
f"instance. Expected a callable, got {type(func)}."
)
if getattr(func, "_flow_with_job", False):
raise FlowProjectDefinitionError(
"The with_job option cannot be used with aggregation."
)
current_agg = getattr(func, "_flow_aggregate", None)
if current_agg is not None and current_agg != aggregator.groupsof(1):
raise FlowProjectDefinitionError(
"Cannot specify aggregates in function and decorator."
)
setattr(func, "_flow_aggregate", self)
return func


class _BaseAggregateStore(Mapping):
"""Base abstract class for aggregate stores.
Expand Down
87 changes: 30 additions & 57 deletions flow/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
_add_cwd_to_environment_pythonpath,
_bidict,
_cached_partial,
_deprecated_warning,
_get_parallel_executor,
_positive_int,
_roundrobin,
Expand Down Expand Up @@ -634,12 +633,10 @@ class FlowGroupEntry:
Operation functions can be marked for inclusion into a :class:`FlowGroup`
by decorating the functions with a corresponding :class:`FlowGroupEntry`.
If the operation requires specific directives, :meth:`~.with_directives`
accepts keyword arguments that are mapped to directives and returns a
decorator that can be applied to the operation to mark it for inclusion in
the group and indicate that it should be executed using the specified
directives. This overrides the default directives specified by
:meth:`flow.directives`.
If the operation requires group specific directives, calling the
:class:`FlowGroupEntry` with the keyword argument ``directives`` allows the
setting of directives for the exclusively for the group. Doing this overrides
the default directives specified by :meth:`FlowProject.operation`.
Parameters
----------
Expand Down Expand Up @@ -673,7 +670,7 @@ def __init__(
# `@operation`.
self.group_aggregator = group_aggregator

def __call__(self, func):
def __call__(self, func=None, /, *, directives=None):
"""Add the function into the group's operations.
This call operator allows the class to be used as a decorator.
Expand All @@ -683,12 +680,23 @@ def __call__(self, func):
func : callable
The function to decorate.
directives : dict
Directives to use for resource requests and execution.
The directives specified in this decorator are only applied when
executing the operation through the :class:`FlowGroup`.
To apply directives to an individual operation executed outside of the
group, see :meth:`.FlowProject.operation`.
Returns
-------
callable
func
The decorated function.
"""
if func is None:
return functools.partial(self._internal_call, directives=directives)
return self._internal_call(func, directives=directives)

def _internal_call(self, func, /, *, directives):
if not any(
func == op_func for _, op_func in self._project._OPERATION_FUNCTIONS
):
Expand All @@ -702,6 +710,13 @@ def __call__(self, func):
f"Cannot reregister operation '{func}' with the group '{self.name}'."
)
func._flow_groups[self._project].add(self.name)
if directives is None:
return func

if hasattr(func, "_flow_group_operation_directives"):
func._flow_group_operation_directives[self.name] = directives
else:
func._flow_group_operation_directives = {self.name: directives}
return func

def _set_directives(self, func, directives):
Expand All @@ -715,38 +730,6 @@ def _set_directives(self, func, directives):
else:
func._flow_group_operation_directives = {self.name: directives}

def with_directives(self, directives):
"""Decorate an operation to provide additional execution directives for this group.
Directives can be used to provide information about required resources
such as the number of processors required for execution of parallelized
operations. For a list of supported directives, see
:meth:`.FlowProject.operation.with_directives`. For more information,
see :ref:`signac-docs:cluster_submission_directives`.
The directives specified in this decorator are only applied when
executing the operation through the :class:`FlowGroup`.
To apply directives to an individual operation executed outside of the
group, see :meth:`.FlowProject.operation`.
Parameters
----------
directives : dict
Directives to use for resource requests and execution.
Returns
-------
function
A decorator which registers the operation with the group using the
specified directives.
"""

def decorator(func):
self._set_directives(func, directives)
return self(func)

return decorator


class FlowGroup:
"""A :class:`~.FlowGroup` represents a subset of a workflow for a project.
Expand All @@ -763,7 +746,7 @@ class FlowGroup:
group = FlowProject.make_group(name='example_group')
@group.with_directives({"nranks": 4})
@group(directives={"nranks": 4})
@FlowProject.operation({"nranks": 2, "executable": "python3"})
def op1(job):
pass
Expand Down Expand Up @@ -1291,13 +1274,8 @@ def __call__(self, func):
func for name, func in self._parent_class._collect_operations()
]
if func not in operation_functions:
_deprecated_warning(
deprecation="Placing conditions below the @FlowProject.operation "
"decorator.",
alternative="Place decorator above @FlowProject.operation to remove the "
"warning.",
deprecated_in="0.23.0",
removed_in="0.24.0",
raise FlowProjectDefinitionError(
"Conditions must come after (above) @FlowProject.operation."
)
if self.condition in operation_functions:
raise FlowProjectDefinitionError(
Expand Down Expand Up @@ -1391,13 +1369,8 @@ def __call__(self, func):
func for name, func in self._parent_class._collect_operations()
]
if func not in operation_functions:
_deprecated_warning(
deprecation="Placing conditions below the @FlowProject.operation "
"decorator.",
alternative="Place decorator above @FlowProject.operation to remove the "
"warning.",
deprecated_in="0.23.0",
removed_in="0.24.0",
raise FlowProjectDefinitionError(
"Conditions must come after (above) @FlowProject.operation."
)
if self.condition in operation_functions:
raise FlowProjectDefinitionError(
Expand Down
2 changes: 1 addition & 1 deletion flow/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# This software is licensed under the BSD 3-Clause License.
"""Define the signac-flow version."""

__version__ = "0.22.0"
__version__ = "0.23.0"

__all__ = ["__version__"]
2 changes: 1 addition & 1 deletion requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
click>=7.0
ruamel.yaml>=0.16.12
pre-commit==2.20.0
pre-commit==2.21.0
2 changes: 1 addition & 1 deletion requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
click==8.1.3
coverage==6.5.0
coverage==7.0.1
pytest-cov==4.0.0
pytest==7.2.0
ruamel.yaml==0.17.21
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.22.0
current_version = 0.23.0
commit = True
tag = False
message = Bump up to version {new_version}.
Expand Down
Loading

0 comments on commit d31c9d7

Please sign in to comment.