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

Native workflow backend #99

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions src/pymorize/cmorizer.py
Original file line number Diff line number Diff line change
@@ -355,6 +355,10 @@ def _post_init_create_pipelines(self):
if isinstance(p, Pipeline):
pipelines.append(p)
elif isinstance(p, dict):
p["workflow_backend"] = p.get(
"workflow_backend",
self._pymorize_cfg("pipeline_workflow_orchestrator"),
)
pl = Pipeline.from_dict(p)
if self._cluster is not None:
pl.assign_cluster(self._cluster)
@@ -495,6 +499,10 @@ def from_dict(cls, data):
if not PIPELINES_VALIDATOR.validate({"pipelines": data["pipelines"]}):
raise ValueError(PIPELINES_VALIDATOR.errors)
for pipeline in data.get("pipelines", []):
pipeline["workflow_backend"] = pipeline.get(
"workflow_backend",
instance._pymorize_cfg("pipeline_workflow_orchestrator"),
)
pipeline_obj = Pipeline.from_dict(pipeline)
instance.add_pipeline(pipeline_obj)

3 changes: 2 additions & 1 deletion src/pymorize/config.py
Original file line number Diff line number Diff line change
@@ -154,12 +154,13 @@ class Config:
parser=_parse_bool, default="yes", doc="Whether to run in parallel."
)
parallel_backend = Option(default="dask", doc="Which parallel backend to use.")
pipeline_workflow_orcherstator = Option(
pipeline_workflow_orchestrator = Option(
default="prefect",
doc="Which workflow orchestrator to use for running pipelines",
parser=ChoiceOf(
str,
choices=[
"native",
"prefect",
],
),
11 changes: 8 additions & 3 deletions src/pymorize/pipeline.py
Original file line number Diff line number Diff line change
@@ -22,17 +22,19 @@ def __init__(
self,
*args,
name=None,
workflow_backend="prefect",
workflow_backend=None,
cache_policy=None,
dask_cluster=None,
cache_expiration=None,
):
self._steps = args
self.name = name or randomname.get_name()
self._workflow_backend = workflow_backend
self._cluster = dask_cluster
self._prefect_cache_kwargs = {}
self._steps_are_prefectized = False
if workflow_backend is None:
workflow_backend = "prefect"
self._workflow_backend = workflow_backend
if cache_policy is None:
self._cache_policy = TASK_SOURCE + INPUTS
self._prefect_cache_kwargs["cache_policy"] = self._cache_policy
@@ -189,13 +191,16 @@ def from_dict(cls, data):
if "uses" in data:
# FIXME(PG): This is bad. What if I need to pass arguments to the constructor?
return get_callable_by_name(data["uses"])(
name=data.get("name"), cache_expiration=data.get("cache_expiration")
name=data.get("name"),
cache_expiration=data.get("cache_expiration"),
workflow_backend=data.get("workflow_backend"),
)
if "steps" in data:
return cls.from_callable_strings(
data["steps"],
name=data.get("name"),
cache_expiration=data.get("cache_expiration"),
workflow_backend=data.get("workflow_backend"),
)
raise ValueError("Pipeline data must have 'uses' or 'steps' key")


Unchanged files with check annotations Beta

default_language_version:

Check warning on line 1 in .pre-commit-config.yaml

GitHub Actions / check_format (3.9)

1:1 [document-start] missing document start "---"
python: python3.9
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: '7.1.1'
hooks:
- id: flake8
# YAML stuff from https://earth.bsc.es/gitlab/digital-twins/de_340-2/workflow

Check warning on line 25 in .pre-commit-config.yaml

GitHub Actions / check_format (3.9)

25:9 [comments-indentation] comment not indented like content

Check warning on line 25 in .pre-commit-config.yaml

GitHub Actions / check_format (3.9)

25:81 [line-length] line too long (85 > 80 characters)
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1 # or higher tag

Check warning on line 27 in .pre-commit-config.yaml

GitHub Actions / check_format (3.9)

27:18 [comments] too few spaces before comment
hooks:
- id: yamllint
args: [-d, "{extends: default, rules: {line-length: {level: 'warning'}}}"]

Check warning on line 30 in .pre-commit-config.yaml

GitHub Actions / check_format (3.9)

30:81 [line-length] line too long (82 > 80 characters)
exclude: |
(?x) # Enable verbose regex
(
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 2

Check warning on line 6 in .readthedocs.yaml

GitHub Actions / check_format (3.9)

6:1 [document-start] missing document start "---"
# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

Check warning on line 1 in .github/workflows/CI-test.yaml

GitHub Actions / check_format (3.9)

1:81 [line-length] line too long (118 > 80 characters)
name: Run Basic Tests

Check warning on line 3 in .github/workflows/CI-test.yaml

GitHub Actions / check_format (3.9)

3:1 [document-start] missing document start "---"
on:

Check warning on line 4 in .github/workflows/CI-test.yaml

GitHub Actions / check_format (3.9)

4:1 [truthy] truthy value should be one of [false, true]
push:
branches: ["main"]
pull_request:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if ${{ matrix.python-version == '3.12' }}; then pip install --upgrade setuptools; fi

Check warning on line 31 in .github/workflows/CI-test.yaml

GitHub Actions / check_format (3.9)

31:81 [line-length] line too long (94 > 80 characters)
- name: Install package
run: |
python -m pip install .[dev,fesom]