Skip to content

Commit 656515e

Browse files
Dana SinghDana Singh
authored andcommitted
#203 Add cylc pre-configure plugin
1 parent 3dbbbf2 commit 656515e

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

.github/workflows/create_test_conda_env.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ jobs:
4848
# add conda env's executables to github's PATH equiv.
4949
echo $CONDA/envs/fre-workflows/bin >> $GITHUB_PATH
5050
51+
- name: Check pre-configure plugin registered correctly
52+
run: |
53+
cylc long --version
54+
exit 1
55+
5156
- name: cylc lint workflow files
5257
run: |
5358
cylc lint -v

install-plugin/__init__.py

Whitespace-only changes.

install-plugin/hello_world.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from cylc.flow import LOG
2+
from pathlib import Path
3+
import yaml
4+
5+
def pre_configure(srcdir=None, opts=None, rundir="/home/Dana.Singh/cylc-run"):
6+
LOG.info("PLUGIN OUTPUT")
7+
LOG.info("Hello world. How the heck are you?")
8+
9+
yml_info = {}
10+
yaml_file = Path(f"{srcdir}/resolved.yaml")
11+
if yaml_file:
12+
yf = yaml_file #[0]
13+
with open(yf, 'r') as f:
14+
yml_info = yaml.safe_load(f)
15+
16+
LOG.info(yml_info)
17+
return {'template_variables': yml_info,
18+
'templating_detected': 'jinja2'}
19+
20+
## want this script to accept resolved yaml and create everything needed to run workflow
21+
# - in dictionary format
22+
# - gets rid of rose-suite.conf
23+
# - removes dependency on cylc-rose...I think
24+
25+
## questions/notes:
26+
# - can function in this script be anything? or does it need to be post_install to be recognized? (as a plugin type)
27+
# - I think it can be anything as long as its registered under one of the plugin types in setup.py

setup.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# plugins must be properly installed, in-place PYTHONPATH meddling will not work.
2+
3+
from setuptools import setup
4+
5+
## Register plugin
6+
setup(
7+
name='hello-world',
8+
version='1.0',
9+
py_modules=['hello_world'], #name of file
10+
entry_points={
11+
# group name: ["plugin_name = module:function"]
12+
'cylc.pre_configure': [
13+
'hw = hello_world:pre_configure'
14+
],
15+
}
16+
)
17+

0 commit comments

Comments
 (0)