Skip to content

Commit 5973420

Browse files
committed
update to json2args 0.6.2
1 parent 1bd5f51 commit 5973420

5 files changed

Lines changed: 32 additions & 14 deletions

File tree

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
FROM python:3.12
33

44
# install the toolbox runner tools
5-
RUN pip install json2args
5+
RUN pip install "json2args[data]>=0.6.2"
66

7+
# if you do not need data-preloading as your tool does that on its own
8+
# you can use this instread of the line above to use a json2args version
9+
# with less dependencies
10+
# RUN pip install json2args>=0.6.2
711

812
# Do anything you need to install tool dependencies here
913
RUN echo "Replace this line with a tool"

in/input.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"foobar": {
3+
"parameters": {
4+
"foo_int": 42,
5+
"foo_float": 13.37,
6+
"foo_string": "Never eat yellow snow",
7+
"foo_enum": "bar",
8+
"foo_array": [34, 55, 23, 43, 23]
9+
},
10+
"data": {
11+
"foo_matrix": "/in/foo_matrix.dat",
12+
"foo_csv": "/in/foo_csv.csv"
13+
}
14+
}
15+
}

in/parameters.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/run.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from pprint import pprint
44

55
from json2args import get_parameter
6+
from json2args.data import get_data
67

78
# parse parameters
89
kwargs = get_parameter()
10+
data = get_data(as_dict=True)
911

1012
# check if a toolname was set in env
1113
toolname = os.environ.get('TOOL_RUN', 'foobar').lower()
@@ -18,6 +20,11 @@
1820
# write parameters to STDOUT.log
1921
pprint(kwargs)
2022

23+
for name, ds in data.items():
24+
print(f"\n### {name}")
25+
print(ds)
26+
27+
2128
# In any other case, it was not clear which tool to run
2229
else:
2330
raise AttributeError(f"[{dt.now().isocalendar()}] Either no TOOL_RUN environment variable available, or '{toolname}' is not valid.\n")

src/tool.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ tools:
1919
foo_array:
2020
type: integer
2121
array: true
22+
data:
2223
foo_matrix:
23-
type: file
24+
extension: dat
25+
description: A matrix file that can be read by numpy
2426
foo_csv:
25-
type: file
27+
extension: csv
28+
description: A standard formatted CSV file, for autoloading using pandas

0 commit comments

Comments
 (0)