Skip to content

Commit a6e3f9d

Browse files
committed
lint
1 parent b6c1674 commit a6e3f9d

8 files changed

Lines changed: 16 additions & 31 deletions

File tree

datatorch/agent/client.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def agent_steps(self):
7878
}
7979
""" % STEP_DISPATCH_FIELDS)
8080
# fmt: on
81-
return cast(
82-
AsyncGenerator[AgentStepRequest, None], self.session.subscribe(sub)
83-
)
81+
return cast(AsyncGenerator[AgentStepRequest, None], self.session.subscribe(sub))
8482

8583
def agent_step_cancels(self):
8684
"""Subscribe to stop signals for steps this agent is running.
@@ -156,9 +154,7 @@ async def complete_step(
156154
step_input["renderedInput"] = rendered_input
157155
if error_message is not None:
158156
step_input["errorMessage"] = error_message
159-
result = await self.execute(
160-
mutate, params={"id": step_id, "input": step_input}
161-
)
157+
result = await self.execute(mutate, params={"id": step_id, "input": step_input})
162158
return bool(result.get("completed"))
163159

164160
def initial_metrics(self, metrics):

datatorch/agent/pipelines/resolver.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
raises rather than passing a literal ``${{ }}`` to the action. A yaml that
2121
uses job dependencies is a server-executed workflow.
2222
"""
23+
2324
import json
2425
import re
2526
from typing import Any, Dict, List, Set, Tuple
@@ -29,7 +30,9 @@
2930
# The name group is ``[^}]+?`` (not ``.+?``) so it can't backtrack across a
3031
# ``}}`` boundary — a string that both starts and ends with a ref must not be
3132
# mistaken for one spanning ref.
32-
STEP_REF = r"\$\{\{\s*steps\.(?P<stepName>[^}]+?)\.outputs?\.(?P<stepKey>[\w.\-]+)\s*\}\}"
33+
STEP_REF = (
34+
r"\$\{\{\s*steps\.(?P<stepName>[^}]+?)\.outputs?\.(?P<stepKey>[\w.\-]+)\s*\}\}"
35+
)
3336
INPUT_REF = r"\$\{\{\s*inputs?\.(?P<inputKey>[\w.\-]+)\s*\}\}"
3437
JOB_REF = r"\$\{\{\s*jobs\.(?P<jobName>[^}]+?)\.outputs?\.(?P<jobKey>[\w.\-]+)\s*\}\}"
3538

@@ -123,9 +126,7 @@ def replace(match: "re.Match") -> str:
123126
]
124127
if isinstance(value, dict):
125128
return {
126-
k: _resolve(
127-
v, outputs_by_name, trigger_input, job_outputs_by_name, misses
128-
)
129+
k: _resolve(v, outputs_by_name, trigger_input, job_outputs_by_name, misses)
129130
for k, v in value.items()
130131
}
131132
return value

datatorch/agent/pipelines/step/step.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ class Step(object):
2525
"""
2626

2727
@classmethod
28-
def from_dispatch(
29-
cls, dispatch: "AgentStepDispatch", api: "AgentApiClient" = None
30-
):
28+
def from_dispatch(cls, dispatch: "AgentStepDispatch", api: "AgentApiClient" = None):
3129
return cls(
3230
id=dispatch.get("stepId"),
3331
action=dispatch.get("action", ""),

datatorch/agent/pipelines/template.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
# data (trigger payloads, fetched step outputs); splicing them into a shell
1818
# string is command injection, so shell/cmd runners must read them from
1919
# $INPUT_<NAME> env vars instead.
20-
_INPUT_REF_IN_TEMPLATE = re.compile(
21-
r"\$\{[{%][^}]*?(?<![.\w])(?:input|variable)(?!\w)"
22-
)
20+
_INPUT_REF_IN_TEMPLATE = re.compile(r"\$\{[{%][^}]*?(?<![.\w])(?:input|variable)(?!\w)")
2321

2422

2523
class InputInjectionError(Exception):
@@ -146,9 +144,7 @@ def render_command(self, string: str):
146144
"policy; see docs/Pipelines.md.)"
147145
)
148146
context = {
149-
k: v
150-
for k, v in self.variables.items()
151-
if k not in ("input", "variable")
147+
k: v for k, v in self.variables.items() if k not in ("input", "variable")
152148
}
153149
return self._template(string).render({**global_variables, **context})
154150

test/agents/pipelines/test_local_pipeline.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
the same dataflow the server orchestrator drives in production, exercised
55
through the cmd runner's ``::key::value`` output protocol.
66
"""
7+
78
import asyncio
89
import os
910
import unittest

test/agents/pipelines/test_resolver.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def test_recurses_into_arrays_and_objects(self):
6464
"nested": {"deep": {"v": "${{ steps.Fetch.output.ok }}"}},
6565
}
6666
)
67-
self.assertEqual(
68-
value, {"list": [42, "x"], "nested": {"deep": {"v": True}}}
69-
)
67+
self.assertEqual(value, {"list": [42, "x"], "nested": {"deep": {"v": True}}})
7068

7169
def test_collects_unresolved_and_leaves_untouched(self):
7270
value, unresolved = resolve(
@@ -117,9 +115,7 @@ def test_job_output_ref_resolves_when_supplied(self):
117115
{},
118116
{"build": {"artifact": "app.tar"}},
119117
)
120-
self.assertEqual(
121-
value, {"raw": "app.tar", "msg": "built app.tar"}
122-
)
118+
self.assertEqual(value, {"raw": "app.tar", "msg": "built app.tar"})
123119
self.assertEqual(unresolved, [])
124120

125121
def test_job_outputs_alias(self):
@@ -131,8 +127,6 @@ def test_job_outputs_alias(self):
131127
def test_job_output_unresolvable_in_local_mode(self):
132128
# Local mode supplies no job outputs (single-job execution), so a
133129
# jobs.* reference is a strict miss rather than a silent pass-through.
134-
value, unresolved = resolve(
135-
{"x": "${{ jobs.build.outputs.artifact }}"}
136-
)
130+
value, unresolved = resolve({"x": "${{ jobs.build.outputs.artifact }}"})
137131
self.assertEqual(value["x"], "${{ jobs.build.outputs.artifact }}")
138132
self.assertEqual(unresolved, ["${{ jobs.build.outputs.artifact }}"])

test/agents/pipelines/test_runner_cancel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
the runner must kill its child process instead of orphaning it, and let the
55
CancelledError propagate so the step aborts.
66
"""
7+
78
import asyncio
89

910
import pytest

test/agents/pipelines/test_template.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def test_variable_is_an_alias_of_input(self):
3434
def test_string_inputs_render_machine_local_refs(self):
3535
v = Variables()
3636
v.add_input("path", "${{ directory.temp }}/x")
37-
self.assertEqual(
38-
v.inputs["path"], global_variables["directory"]["temp"] + "/x"
39-
)
37+
self.assertEqual(v.inputs["path"], global_variables["directory"]["temp"] + "/x")
4038

4139
def test_retired_namespaces_raise(self):
4240
# job/run/pipeline/trigger/event are server-side concepts now; the

0 commit comments

Comments
 (0)