Skip to content
Snippets Groups Projects
Commit a8371a93 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

set PYPUSHFLOW_OBJECTID to job id when needed

parent 96ed8fbf
No related branches found
No related tags found
1 merge request!115Resolve "PYPUSHFLOW_OBJECTID (or the db_options) should get the workflow job id"
Pipeline #224284 passed
......@@ -2,7 +2,10 @@
## Unreleased
Changes:
- Drop Python 3.6 and 3.7
- Set deprecated environment variable `PYPUSHFLOW_OBJECTID` to the Ewoks job id when needed.
## 1.0.0
......
......@@ -15,7 +15,7 @@ classifiers = [
"Programming Language :: Python :: 3",
]
requires-python = ">=3.8"
dependencies = ["ewokscore >=1.0.0", "pypushflow >=1.0.0"]
dependencies = ["ewokscore >=1.0.0", "pypushflow >=1.1.0"]
[project.urls]
Homepage = "https://gitlab.esrf.fr/workflow/ewoks/ewoksppf/"
......
import os
import pprint
from contextlib import contextmanager
from typing import Generator, Optional, List, Sequence
......@@ -592,6 +593,11 @@ def execute_graph(
if load_options is None:
load_options = dict()
ewoksgraph = load_graph(graph, inputs=inputs, **load_options)
_deprecated_pypushflow_environment_variables(
db_options=db_options, **execute_options
)
ppfgraph = EwoksWorkflow(
ewoksgraph,
pre_import=pre_import,
......@@ -601,3 +607,31 @@ def execute_graph(
db_options=db_options,
)
return ppfgraph.run(**execute_options)
def _deprecated_pypushflow_environment_variables(
db_options: Optional[dict] = None, execinfo: Optional[dict] = None, **_
) -> None:
if db_options and db_options.get("db_type") is not None:
return
# We are still using the deprecated PYPUSHFLOW_* environment variables.
if not os.environ.get("PYPUSHFLOW_MONGOURL", None):
return
# pypushflow needs PYPUSHFLOW_OBJECTID to be defined. All the others have defaults.
if os.environ.get("PYPUSHFLOW_OBJECTID", None):
return
if not execinfo:
return
job_id = execinfo.get("job_id", None)
if not job_id:
return
# We do have an Ewoks job ID so use it for PYPUSHFLOW_OBJECTID.
os.environ["PYPUSHFLOW_OBJECTID"] = str(job_id)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment