Skip to content

Commit 6fd6fdb

Browse files
committed
black 20.8b1
1 parent 20d1254 commit 6fd6fdb

24 files changed

+229
-112
lines changed

cwltool/builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,9 @@ def addsf(
519519
ll = schema.get("loadListing") or self.loadListing
520520
if ll and ll != "no_listing":
521521
get_listing(
522-
self.fs_access, datum, (ll == "deep_listing"),
522+
self.fs_access,
523+
datum,
524+
(ll == "deep_listing"),
523525
)
524526
self.files.append(datum)
525527

cwltool/command_line_tool.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ def _initialworkdir(self, j: JobBase, builder: Builder) -> None:
485485
# "listing" is an array of either expressions or Dirent so
486486
# evaluate each item
487487
for t in cast(
488-
MutableSequence[Union[str, CWLObjectType]], initialWorkdir["listing"],
488+
MutableSequence[Union[str, CWLObjectType]],
489+
initialWorkdir["listing"],
489490
):
490491
if isinstance(t, Mapping) and "entry" in t:
491492
# Dirent
@@ -672,7 +673,9 @@ def remove_dirname(d: CWLObjectType) -> None:
672673
del d["dirname"]
673674

674675
visit_class(
675-
entry["listing"], ("File", "Directory"), remove_dirname,
676+
entry["listing"],
677+
("File", "Directory"),
678+
remove_dirname,
676679
)
677680

678681
visit_class(

cwltool/cwlrdf.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,5 @@ def printdot(
195195
ctx: ContextType,
196196
stdout: Union[TextIO, StreamWriter],
197197
) -> None:
198-
cwl_viewer = CWLViewer(printrdf(wf, ctx, 'n3')) # type: CWLViewer
199-
stdout.write(
200-
cwl_viewer.dot()
201-
)
198+
cwl_viewer = CWLViewer(printrdf(wf, ctx, "n3")) # type: CWLViewer
199+
stdout.write(cwl_viewer.dot())

cwltool/cwlviewer.py

Lines changed: 78 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,119 +8,149 @@
88
class CWLViewer:
99
"""Produce similar images with the https://github.com/common-workflow-language/cwlviewer."""
1010

11-
_queries_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'rdfqueries')
12-
_get_inner_edges_query_path = os.path.join(_queries_dir, 'get_inner_edges.sparql')
13-
_get_input_edges_query_path = os.path.join(_queries_dir, 'get_input_edges.sparql')
14-
_get_output_edges_query_path = os.path.join(_queries_dir, 'get_output_edges.sparql')
15-
_get_root_query_path = os.path.join(_queries_dir, 'get_root.sparql')
11+
_queries_dir = os.path.join(
12+
os.path.abspath(os.path.dirname(__file__)), "rdfqueries"
13+
)
14+
_get_inner_edges_query_path = os.path.join(_queries_dir, "get_inner_edges.sparql")
15+
_get_input_edges_query_path = os.path.join(_queries_dir, "get_input_edges.sparql")
16+
_get_output_edges_query_path = os.path.join(_queries_dir, "get_output_edges.sparql")
17+
_get_root_query_path = os.path.join(_queries_dir, "get_root.sparql")
1618

1719
def __init__(
18-
self,
19-
rdf_description # type: str
20+
self, rdf_description # type: str
2021
):
2122
"""Create a viewer object based on the rdf description of the workflow."""
2223
self._dot_graph = CWLViewer._init_dot_graph() # type: pydot.Graph
23-
self._rdf_graph = self._load_cwl_graph(rdf_description) # type: rdflib.graph.Graph
24+
self._rdf_graph = self._load_cwl_graph(
25+
rdf_description
26+
) # type: rdflib.graph.Graph
2427
self._root_graph_uri = self._get_root_graph_uri() # type: str
2528
self._set_inner_edges()
2629
self._set_input_edges()
2730
self._set_output_edges()
2831

2932
def _load_cwl_graph(
30-
self,
31-
rdf_description # type: str
33+
self, rdf_description # type: str
3234
) -> rdflib.graph.Graph:
3335
rdf_graph = rdflib.Graph()
34-
rdf_graph.parse(data=rdf_description, format='n3')
36+
rdf_graph.parse(data=rdf_description, format="n3")
3537
return rdf_graph
3638

3739
def _set_inner_edges(self) -> None:
3840
with open(self._get_inner_edges_query_path) as f:
3941
get_inner_edges_query = f.read()
40-
inner_edges = self._rdf_graph.query(get_inner_edges_query, initBindings={'root_graph': self._root_graph_uri})
42+
inner_edges = self._rdf_graph.query(
43+
get_inner_edges_query, initBindings={"root_graph": self._root_graph_uri}
44+
)
4145
for inner_edge_row in inner_edges:
42-
source_label = inner_edge_row['source_label'] \
43-
if inner_edge_row['source_label'] is not None \
44-
else urlparse(inner_edge_row['source_step']).fragment
46+
source_label = (
47+
inner_edge_row["source_label"]
48+
if inner_edge_row["source_label"] is not None
49+
else urlparse(inner_edge_row["source_step"]).fragment
50+
)
4551
n = pydot.Node(
46-
'',
47-
fillcolor='lightgoldenrodyellow', style="filled",
52+
"",
53+
fillcolor="lightgoldenrodyellow",
54+
style="filled",
4855
label=source_label,
49-
shape='record'
56+
shape="record",
5057
)
51-
n.set_name(str(inner_edge_row['source_step']))
58+
n.set_name(str(inner_edge_row["source_step"]))
5259
self._dot_graph.add_node(n)
53-
target_label = inner_edge_row['target_label'] \
54-
if inner_edge_row['target_label'] is not None \
55-
else urlparse(inner_edge_row['target_step']).fragment
60+
target_label = (
61+
inner_edge_row["target_label"]
62+
if inner_edge_row["target_label"] is not None
63+
else urlparse(inner_edge_row["target_step"]).fragment
64+
)
5665
n = pydot.Node(
57-
'',
58-
fillcolor='lightgoldenrodyellow', style="filled",
66+
"",
67+
fillcolor="lightgoldenrodyellow",
68+
style="filled",
5969
label=target_label,
60-
shape='record'
70+
shape="record",
6171
)
62-
n.set_name(str(inner_edge_row['target_step']))
72+
n.set_name(str(inner_edge_row["target_step"]))
6373
self._dot_graph.add_node(n)
64-
self._dot_graph.add_edge(pydot.Edge(str(inner_edge_row['source_step']), str(inner_edge_row['target_step'])))
74+
self._dot_graph.add_edge(
75+
pydot.Edge(
76+
str(inner_edge_row["source_step"]),
77+
str(inner_edge_row["target_step"]),
78+
)
79+
)
6580

6681
def _set_input_edges(self) -> None:
6782
with open(self._get_input_edges_query_path) as f:
6883
get_input_edges_query = f.read()
6984
inputs_subgraph = pydot.Subgraph(graph_name="cluster_inputs")
7085
self._dot_graph.add_subgraph(inputs_subgraph)
7186
inputs_subgraph.set_rank("same")
72-
inputs_subgraph.create_attribute_methods(['style'])
87+
inputs_subgraph.create_attribute_methods(["style"])
7388
inputs_subgraph.set_style("dashed")
7489
inputs_subgraph.set_label("Workflow Inputs")
7590

76-
input_edges = self._rdf_graph.query(get_input_edges_query, initBindings={'root_graph': self._root_graph_uri})
91+
input_edges = self._rdf_graph.query(
92+
get_input_edges_query, initBindings={"root_graph": self._root_graph_uri}
93+
)
7794
for input_row in input_edges:
7895
n = pydot.Node(
79-
'',
96+
"",
8097
fillcolor="#94DDF4",
8198
style="filled",
82-
label=urlparse(input_row['input']).fragment,
83-
shape='record'
99+
label=urlparse(input_row["input"]).fragment,
100+
shape="record",
84101
)
85-
n.set_name(str(input_row['input']))
102+
n.set_name(str(input_row["input"]))
86103
inputs_subgraph.add_node(n)
87-
self._dot_graph.add_edge(pydot.Edge(str(input_row['input']), str(input_row['step'])))
104+
self._dot_graph.add_edge(
105+
pydot.Edge(str(input_row["input"]), str(input_row["step"]))
106+
)
88107

89108
def _set_output_edges(self) -> None:
90109
with open(self._get_output_edges_query_path) as f:
91110
get_output_edges = f.read()
92111
outputs_graph = pydot.Subgraph(graph_name="cluster_outputs")
93112
self._dot_graph.add_subgraph(outputs_graph)
94113
outputs_graph.set_rank("same")
95-
outputs_graph.create_attribute_methods(['style'])
114+
outputs_graph.create_attribute_methods(["style"])
96115
outputs_graph.set_style("dashed")
97116
outputs_graph.set_label("Workflow Outputs")
98117
outputs_graph.set_labelloc("b")
99-
output_edges = self._rdf_graph.query(get_output_edges, initBindings={'root_graph': self._root_graph_uri})
118+
output_edges = self._rdf_graph.query(
119+
get_output_edges, initBindings={"root_graph": self._root_graph_uri}
120+
)
100121
for output_edge_row in output_edges:
101-
n = pydot.Node('',
102-
fillcolor="#94DDF4",
103-
style="filled",
104-
label=urlparse(output_edge_row['output']).fragment,
105-
shape='record'
106-
)
107-
n.set_name(str(output_edge_row['output']))
122+
n = pydot.Node(
123+
"",
124+
fillcolor="#94DDF4",
125+
style="filled",
126+
label=urlparse(output_edge_row["output"]).fragment,
127+
shape="record",
128+
)
129+
n.set_name(str(output_edge_row["output"]))
108130
outputs_graph.add_node(n)
109-
self._dot_graph.add_edge(pydot.Edge(output_edge_row['step'], output_edge_row['output']))
131+
self._dot_graph.add_edge(
132+
pydot.Edge(output_edge_row["step"], output_edge_row["output"])
133+
)
110134

111135
def _get_root_graph_uri(self) -> rdflib.URIRef:
112136
with open(self._get_root_query_path) as f:
113137
get_root_query = f.read()
114-
root = list(self._rdf_graph.query(get_root_query, ))
138+
root = list(
139+
self._rdf_graph.query(
140+
get_root_query,
141+
)
142+
)
115143
if len(root) != 1:
116-
raise RuntimeError("Cannot identify root workflow! Notice that only Workflows can be visualized")
144+
raise RuntimeError(
145+
"Cannot identify root workflow! Notice that only Workflows can be visualized"
146+
)
117147

118-
workflow = root[0]['workflow'] # type: rdflib.URIRef
148+
workflow = root[0]["workflow"] # type: rdflib.URIRef
119149
return workflow
120150

121151
@classmethod
122152
def _init_dot_graph(cls) -> pydot.Graph:
123-
graph = pydot.Graph(graph_type='digraph', simplify=False)
153+
graph = pydot.Graph(graph_type="digraph", simplify=False)
124154
graph.set_bgcolor("#eeeeee")
125155
graph.set_clusterrank("local")
126156
graph.set_labelloc("bottom")

cwltool/executors.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,9 @@ def _runner(self, job, runtime_context, TMPDIR_LOCK):
339339
runtime_context.workflow_eval_lock.notifyAll()
340340

341341
def run_job(
342-
self, job: Optional[JobsType], runtime_context: RuntimeContext,
342+
self,
343+
job: Optional[JobsType],
344+
runtime_context: RuntimeContext,
343345
) -> None:
344346
"""Execute a single Job in a seperate thread."""
345347
if job is not None:
@@ -368,11 +370,10 @@ def run_job(
368370
return
369371

370372
if (
371-
(self.allocated_ram + job.builder.resources["ram"])
372-
> self.max_ram
373-
or (self.allocated_cores + job.builder.resources["cores"])
374-
> self.max_cores
375-
):
373+
self.allocated_ram + job.builder.resources["ram"]
374+
) > self.max_ram or (
375+
self.allocated_cores + job.builder.resources["cores"]
376+
) > self.max_cores:
376377
_logger.debug(
377378
'Job "%s" cannot run yet, resources (%s) are not '
378379
"available (already allocated ram is %d, allocated cores is %d, "

cwltool/job.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ def get_from_requirements(
608608

609609
@abstractmethod
610610
def create_runtime(
611-
self, env: MutableMapping[str, str], runtime_context: RuntimeContext,
611+
self,
612+
env: MutableMapping[str, str],
613+
runtime_context: RuntimeContext,
612614
) -> Tuple[List[str], Optional[str]]:
613615
"""Return the list of commands to run the selected container engine."""
614616

cwltool/load_tool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ def load_tool(
482482

483483

484484
def resolve_overrides(
485-
ov: IdxResultType, ov_uri: str, baseurl: str,
485+
ov: IdxResultType,
486+
ov_uri: str,
487+
baseurl: str,
486488
) -> List[CWLObjectType]:
487489
ovloader = Loader(overrides_ctx)
488490
ret, _ = ovloader.resolve_all(ov, baseurl)

cwltool/main.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ def _signal_handler(signum: int, _: Any) -> None:
132132

133133

134134
def generate_example_input(
135-
inptype: Optional[CWLOutputType], default: Optional[CWLOutputType],
135+
inptype: Optional[CWLOutputType],
136+
default: Optional[CWLOutputType],
136137
) -> Tuple[Any, str]:
137138
"""Convert a single input schema into an example."""
138139
example = None
@@ -401,7 +402,8 @@ def init_job_order(
401402
if "job_order" in cmd_line and cmd_line["job_order"]:
402403
try:
403404
job_order_object = cast(
404-
CWLObjectType, loader.resolve_ref(cmd_line["job_order"])[0],
405+
CWLObjectType,
406+
loader.resolve_ref(cmd_line["job_order"])[0],
405407
)
406408
except Exception:
407409
_logger.exception(
@@ -582,7 +584,10 @@ def loadref(base: str, uri: str) -> Union[CommentedMap, CommentedSeq, str, None]
582584
return deps
583585

584586

585-
def print_pack(loadingContext: LoadingContext, uri: str,) -> str:
587+
def print_pack(
588+
loadingContext: LoadingContext,
589+
uri: str,
590+
) -> str:
586591
"""Return a CWL serialization of the CWL document in JSON."""
587592
packed = pack(loadingContext, uri)
588593
if len(cast(Sized, packed["$graph"])) > 1:
@@ -666,7 +671,9 @@ def formatTime(
666671

667672

668673
def setup_provenance(
669-
args: argparse.Namespace, argsl: List[str], runtimeContext: RuntimeContext,
674+
args: argparse.Namespace,
675+
argsl: List[str],
676+
runtimeContext: RuntimeContext,
670677
) -> Optional[int]:
671678
if not args.compute_checksum:
672679
_logger.error("--provenance incompatible with --no-compute-checksum")
@@ -719,7 +726,9 @@ def setup_loadingContext(
719726
return loadingContext
720727

721728

722-
def make_template(tool: Process,) -> None:
729+
def make_template(
730+
tool: Process,
731+
) -> None:
723732
def my_represent_none(
724733
self: Any, data: Any
725734
) -> Any: # pylint: disable=unused-argument
@@ -737,7 +746,9 @@ def my_represent_none(
737746

738747

739748
def choose_target(
740-
args: argparse.Namespace, tool: Process, loadingContext: LoadingContext,
749+
args: argparse.Namespace,
750+
tool: Process,
751+
loadingContext: LoadingContext,
741752
) -> Optional[Process]:
742753

743754
if loadingContext.loader is None:
@@ -769,7 +780,9 @@ def choose_target(
769780
return tool
770781

771782

772-
def check_working_directories(runtimeContext: RuntimeContext,) -> Optional[int]:
783+
def check_working_directories(
784+
runtimeContext: RuntimeContext,
785+
) -> Optional[int]:
773786
for dirprefix in ("tmpdir_prefix", "tmp_outdir_prefix", "cachedir"):
774787
if (
775788
getattr(runtimeContext, dirprefix)

cwltool/pack.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030

3131
def find_run(
32-
d: Union[CWLObjectType, ResolveType], loadref: LoadRefType, runs: Set[str],
32+
d: Union[CWLObjectType, ResolveType],
33+
loadref: LoadRefType,
34+
runs: Set[str],
3335
) -> None:
3436
if isinstance(d, MutableSequence):
3537
for s in d:

cwltool/pathmapper.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ def visit(
118118
) -> None:
119119
stagedir = cast(Optional[str], obj.get("dirname")) or stagedir
120120
tgt = convert_pathsep_to_unix(
121-
os.path.join(stagedir, cast(str, obj["basename"]),)
121+
os.path.join(
122+
stagedir,
123+
cast(str, obj["basename"]),
124+
)
122125
)
123126
if obj["location"] in self._pathmap:
124127
return
@@ -212,7 +215,10 @@ def files(self) -> List[str]:
212215
def items(self) -> List[Tuple[str, MapperEnt]]:
213216
return list(self._pathmap.items())
214217

215-
def reversemap(self, target: str,) -> Optional[Tuple[str, str]]:
218+
def reversemap(
219+
self,
220+
target: str,
221+
) -> Optional[Tuple[str, str]]:
216222
for k, v in self._pathmap.items():
217223
if v[1] == target:
218224
return (k, v[0])

0 commit comments

Comments
 (0)