In the workflows/
directory, ng6 provides a types.py
file where new types can be added.
ng6/
├── bin/
├── docs/
├── src/
├── workflows/
│ ├── components/
│ ├── extparsers/
│ ├── __init__.py
│ ├── formats.py
│ └── types.py [ file where to add new jflow types ]
├── applications.properties
└── README
In ng6 a type is represented by a function named by the desired type name. The function should take only
one argument, whose value is given by the user. The function is in charge to check and/or modify
the given value. If an error occurred or if the value does not meet the expected criteria, an
argparse.ArgumentTypeError
should be raised with the suitable error message. This message will
be used by ng6 to inform the final user of the error.
In the following example, the intBetween1and100
function checks if the input value is in between
1 and 100:
def intBetween1and100(myint):
# the input argument type is allways a string
try:
myint = int(myint)
except:
raise argparse.ArgumentTypeError("'"+str(myint)+"' is not a valid int!")
if myint <= 100 and myint >= 1:
return myint
else:
raise argparse.ArgumentTypeError("'"+str(myint)+"' is not between 1 and 100!")
The new created type can then be used in both add_parameter
and add_parameter_list
of
classes jflow.workflow.Workflow
, ng6.ng6workflow.NG6Workflow
,
ng6.ng6workflow.CASAVANG6Workflow
, ng6.analysis.Analysis
and jflow.component.Component
as following:
[...]
def define_parameters(self, function="process"):
self.add_parameter("my_param", "A value in between 1 and 100", type="intBetween1and100")
[...]