Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 58cbe07

Browse files
authored
add local run example (#8)
1 parent f40b903 commit 58cbe07

File tree

7 files changed

+64
-1
lines changed

7 files changed

+64
-1
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.git
22
.tox
3+
venv/

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ build/
77
dist/
88
doc/build
99
doc/source/generated
10+
venv/
1011
.tox

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help python_build docker_build_latest run
1+
.PHONY: help python_build docker_build_latest run install_to_venv
22

33
IMAGE_NAME?=bbp-workflow
44

@@ -23,3 +23,10 @@ docker_build_latest: # python_build
2323

2424
run:
2525
docker run -it --rm --user $$(id -u) -e DEBUG=True $(IMAGE_NAME)
26+
27+
venv:
28+
if python -m ensurepip --version; then python -m venv $@; else virtualenv $@; fi
29+
venv/bin/pip install --upgrade pip
30+
31+
install_to_venv: | venv
32+
venv/bin/pip install --upgrade bbp-workflow

README.rst

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ Tests
2727
pip install tox
2828
tox
2929
30+
Local Run
31+
=========
32+
33+
.. code-block:: bash
34+
35+
make install_to_venv
36+
./bbp-workflow-launch.sh --config workflows/foo.cfg foo Bar dynamic-param=world
37+
3038
Acknowledgements
3139
================
3240

bbp-workflow-launch.sh

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -e
3+
source venv/bin/activate
4+
5+
WORKFLOWS_DIR=$(realpath workflows)
6+
if [[ $1 == '--workflows-dir' ]]; then
7+
WORKFLOWS_DIR=$(realpath "$2")
8+
shift; shift
9+
fi
10+
11+
if [[ $1 == '--config' ]]; then
12+
export LUIGI_CONFIG_PATH=$(realpath "$2")
13+
shift; shift
14+
fi
15+
16+
export PYTHONPATH=$WORKFLOWS_DIR
17+
18+
if [[ "$1" ]]; then
19+
MODULE=$1; shift
20+
else
21+
echo "No module provided!"; exit 1
22+
fi
23+
if [[ "$1" ]]; then
24+
TASK=$1; shift
25+
else
26+
echo "No task provided!"; exit 1
27+
fi
28+
echo LUIGI_CONFIG_PATH=$LUIGI_CONFIG_PATH
29+
echo PYTHONPATH=$PYTHONPATH
30+
for i in "$@"; do
31+
PARAMS="$PARAMS --${i%=*} ${i#*=}"
32+
done
33+
34+
cd $WORKFLOWS_DIR
35+
luigi --local-scheduler --module $MODULE $TASK$PARAMS
36+
echo "exit: $?"

workflows/foo.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Bar]
2+
static-param: hello

workflows/foo.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from luigi import Task, Parameter
2+
3+
4+
class Bar(Task):
5+
static_param = Parameter()
6+
dynamic_param = Parameter()
7+
def run(self):
8+
print(f"\n>>> {self.static_param} {self.dynamic_param}! <<<\n", flush=True)

0 commit comments

Comments
 (0)