Skip to content

Commit

Permalink
update to json2args 0.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaelicke committed Jul 30, 2024
1 parent 1bd5f51 commit 5973420
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
FROM python:3.12

# install the toolbox runner tools
RUN pip install json2args
RUN pip install "json2args[data]>=0.6.2"

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

# Do anything you need to install tool dependencies here
RUN echo "Replace this line with a tool"
Expand Down
15 changes: 15 additions & 0 deletions in/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"foobar": {
"parameters": {
"foo_int": 42,
"foo_float": 13.37,
"foo_string": "Never eat yellow snow",
"foo_enum": "bar",
"foo_array": [34, 55, 23, 43, 23]
},
"data": {
"foo_matrix": "/in/foo_matrix.dat",
"foo_csv": "/in/foo_csv.csv"
}
}
}
11 changes: 0 additions & 11 deletions in/parameters.json

This file was deleted.

7 changes: 7 additions & 0 deletions src/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from pprint import pprint

from json2args import get_parameter
from json2args.data import get_data

# parse parameters
kwargs = get_parameter()
data = get_data(as_dict=True)

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

for name, ds in data.items():
print(f"\n### {name}")
print(ds)


# In any other case, it was not clear which tool to run
else:
raise AttributeError(f"[{dt.now().isocalendar()}] Either no TOOL_RUN environment variable available, or '{toolname}' is not valid.\n")
7 changes: 5 additions & 2 deletions src/tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ tools:
foo_array:
type: integer
array: true
data:
foo_matrix:
type: file
extension: dat
description: A matrix file that can be read by numpy
foo_csv:
type: file
extension: csv
description: A standard formatted CSV file, for autoloading using pandas

0 comments on commit 5973420

Please sign in to comment.