Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
new_connections = list(connections.items())
else:
raise Exception(
"Connections can be a 2-elements tuple, a list of these tuples, or dictionary"
)
# checking if a new output name is already in the connections
connection_names = [name for name, _ in self._connections]
new_names = [name for name, _ in new_connections]
if set(connection_names).intersection(new_names):
raise Exception(
f"output name {set(connection_names).intersection(new_names)} is already set"
)
self._connections += new_connections
fields = [(name, ty.Any) for name, _ in self._connections]
self.output_spec = SpecInfo(name="Output", fields=fields, bases=(BaseSpec,))
logger.info("Added %s to %s", self.output_spec, self)
input_spec : :obj:`pydra.engine.specs.SpecInfo`
Specification of inputs.
messenger_args :
TODO
messengers :
TODO
output_cpath : :obj:`str`
Output path within the container filesystem.
output_spec : :obj:`pydra.engine.specs.BaseSpec`
Specification of inputs.
strip : :obj:`bool`
TODO
"""
if input_spec is None:
input_spec = SpecInfo(name="Inputs", fields=[], bases=(ContainerSpec,))
self.output_cpath = Path(output_cpath)
super(ContainerTask, self).__init__(
name=name,
input_spec=input_spec,
output_spec=output_spec,
audit_flags=audit_flags,
messengers=messengers,
messenger_args=messenger_args,
cache_dir=cache_dir,
strip=strip,
rerun=rerun,
**kwargs,
)
names_subset.remove(name)
path_template = reduce(
lambda s, r: s.replace(*r),
self._input_spec_keys.items(),
output["path-template"],
)
mdata = {
"help_string": output.get("description", None) or output["name"],
"mandatory": not output["optional"],
"output_file_template": path_template,
}
fields.append((name, attr.ib(type=File, metadata=mdata)))
if names_subset:
raise RuntimeError(f"{names_subset} are not in the zenodo output spec")
spec = SpecInfo(name="Outputs", fields=fields, bases=(ShellOutSpec,))
return spec
else:
tp = None
# adding list
if tp and "list" in input and input["list"]:
tp = ty.List[tp]
mdata = {
"help_string": input.get("description", None) or input["name"],
"mandatory": not input["optional"],
"argstr": input.get("command-line-flag", None),
}
fields.append((name, tp, mdata))
self._input_spec_keys[input["value-key"]] = "{" + f"{name}" + "}"
if names_subset:
raise RuntimeError(f"{names_subset} are not in the zenodo input spec")
spec = SpecInfo(name="Inputs", fields=fields, bases=(ShellSpec,))
return spec
+ [
(
nm,
attr.ib(
type=ty.Any,
metadata={
"help_string": f"{nm} input from {name} workflow"
},
),
)
for nm in input_spec
],
bases=(BaseSpec,),
)
if output_spec is None:
output_spec = SpecInfo(
name="Output", fields=[("out", ty.Any)], bases=(BaseSpec,)
)
self.output_spec = output_spec
super(Workflow, self).__init__(
name=name,
inputs=kwargs,
cache_dir=cache_dir,
cache_locations=cache_locations,
audit_flags=audit_flags,
messengers=messengers,
messenger_args=messenger_args,
rerun=rerun,
)
self.graph = DiGraph()
TODO
messengers :
TODO
name : :obj:`str`
Name of this task.
output_spec : :obj:`pydra.engine.specs.BaseSpec`
Specification of inputs.
strip : :obj:`bool`
TODO
"""
if input_spec is None:
input_spec = SpecInfo(name="Inputs", fields=[], bases=(ShellSpec,))
self.input_spec = input_spec
if output_spec is None:
output_spec = SpecInfo(name="Output", fields=[], bases=(ShellOutSpec,))
self.output_spec = output_spec
super(ShellCommandTask, self).__init__(
name=name,
inputs=kwargs,
audit_flags=audit_flags,
messengers=messengers,
messenger_args=messenger_args,
cache_dir=cache_dir,
rerun=rerun,
)
self.strip = strip
new_connections = list(connections.items())
else:
raise Exception(
"Connections can be a 2-elements tuple, a list of these tuples, or dictionary"
)
# checking if a new output name is already in the connections
connection_names = [name for name, _ in self._connections]
new_names = [name for name, _ in new_connections]
if set(connection_names).intersection(new_names):
raise Exception(
f"output name {set(connection_names).intersection(new_names)} is already set"
)
self._connections += new_connections
fields = [(name, ty.Any) for name, _ in self._connections]
self.output_spec = SpecInfo(name="Output", fields=fields, bases=(BaseSpec,))
logger.info("Added %s to %s", self.output_spec, self)
TODO
inputs : :obj:`typing.Text`, or :class:`File`, or :obj:`dict`, or `None`.
Set particular inputs to this node.
messenger_args :
TODO
messengers :
TODO
output_spec :
TODO
"""
if input_spec:
if isinstance(input_spec, BaseSpec):
self.input_spec = input_spec
else:
self.input_spec = SpecInfo(
name="Inputs",
fields=[("_graph_checksums", ty.Any)]
+ [
(
nm,
attr.ib(
type=ty.Any,
metadata={
"help_string": f"{nm} input from {name} workflow"
},
),
)
for nm in input_spec
],
bases=(BaseSpec,),
)
messenger_args=messenger_args,
cache_dir=cache_dir,
cache_locations=cache_locations,
rerun=rerun,
)
if output_spec is None:
if "return" not in func.__annotations__:
output_spec = SpecInfo(
name="Output", fields=[("out", ty.Any)], bases=(BaseSpec,)
)
else:
return_info = func.__annotations__["return"]
if hasattr(return_info, "__name__") and hasattr(
return_info, "__annotations__"
):
output_spec = SpecInfo(
name=return_info.__name__,
fields=list(return_info.__annotations__.items()),
bases=(BaseSpec,),
)
# Objects like int, float, list, tuple, and dict do not have __name__ attribute.
elif hasattr(return_info, "__annotations__"):
output_spec = SpecInfo(
name="Output",
fields=list(return_info.__annotations__.items()),
bases=(BaseSpec,),
)
elif isinstance(return_info, dict):
output_spec = SpecInfo(
name="Output",
fields=list(return_info.items()),
bases=(BaseSpec,),