Skip to content

Commit 2eee941

Browse files
committed
lint with black
1 parent 7a3e887 commit 2eee941

File tree

27 files changed

+90
-78
lines changed

27 files changed

+90
-78
lines changed

datatorch/agent/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def setup_logging() -> None:
5454

5555

5656
async def _exit_jobs() -> None:
57-
""" Exits active running agent jobs """
57+
"""Exits active running agent jobs"""
5858
logger.info(f"Exiting {len(tasks)} active jobs.")
5959

6060
for task in tasks:
@@ -77,7 +77,7 @@ async def _close_transport(transport: WebsocketsTransport):
7777

7878

7979
async def _exit_tasks() -> None:
80-
""" Exits all active asyncio tasks """
80+
"""Exits all active asyncio tasks"""
8181
current_task = asyncio.Task.current_task()
8282
all_tasks = asyncio.Task.all_tasks()
8383
not_current_tasks = [task for task in all_tasks if task is not current_task]
@@ -87,7 +87,7 @@ async def _exit_tasks() -> None:
8787

8888

8989
async def start() -> None:
90-
""" Creates and runs an agent. """
90+
"""Creates and runs an agent."""
9191
setup_logging()
9292

9393
click.echo(
@@ -131,7 +131,7 @@ async def start() -> None:
131131

132132

133133
async def stop() -> None:
134-
""" Stop all run tasks. """
134+
"""Stop all run tasks."""
135135

136136
print(" ")
137137

datatorch/agent/agent.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _init_threads(self):
4646
tasks.append(task)
4747

4848
async def process_loop(self):
49-
""" Waits for jobs from server. """
49+
"""Waits for jobs from server."""
5050
logger.info("Waiting for jobs.")
5151
async for job_request in self.api.agent_jobs():
5252
loop = asyncio.get_event_loop()
@@ -55,7 +55,7 @@ async def process_loop(self):
5555
tasks.append(task)
5656

5757
async def _run_job(self, job: AgentJobConfig):
58-
""" Runs a job """
58+
"""Runs a job"""
5959
job_id = job.get("id")
6060
job_name = job.get("name")
6161
job_steps = job.get("steps")

datatorch/agent/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def __init__(self, session: AsyncClientSession):
5858
self.session = session
5959

6060
def agent_jobs(self):
61-
""" Subscriptions to the agent job assignment namespace. """
61+
"""Subscriptions to the agent job assignment namespace."""
6262
# fmt: off
6363
sub = gql("""
6464
subscription {
@@ -220,7 +220,7 @@ def upload_step_logs(self, step_id: str, logs: List[Log]):
220220
return self.execute(mutate, params={"id": step_id, "logs": logs})
221221

222222
async def execute(self, query, *args, params: dict = {}, **kwargs) -> dict:
223-
""" Wrapper around execute """
223+
"""Wrapper around execute"""
224224
removed_none = dict((k, v) for k, v in params.items() if v is not None)
225225
if type(query) == str:
226226
query = gql(query)

datatorch/agent/directory.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class AgentDirectory(object):
88
@staticmethod
99
def path() -> str:
10-
""" Returns the agents directory """
10+
"""Returns the agents directory"""
1111
path = folder.get_app_dir()
1212
return os.getenv("DATATORCH_AGENT_PATH", os.path.join(path, "agent"))
1313

@@ -36,12 +36,12 @@ def runs_dir(self):
3636

3737
@property
3838
def logs_dir(self):
39-
""" Directory where agent logs are stored. """
39+
"""Directory where agent logs are stored."""
4040
return os.path.join(self.dir, "logs")
4141

4242
@property
4343
def db_dir(self):
44-
""" Sqlite database are stored. """
44+
"""Sqlite database are stored."""
4545
return os.path.join(self.dir, "db")
4646

4747
@property
@@ -55,7 +55,7 @@ def projects_dir(self):
5555

5656
@property
5757
def actions_dir(self):
58-
""" Directory where actions are stored. """
58+
"""Directory where actions are stored."""
5959
return os.path.join(self.dir, "actions")
6060

6161
def open(self, file: str, mode: str):
@@ -65,13 +65,13 @@ def action_dir(self, name: str, version: str):
6565
return os.path.join(self.actions_dir, *name.lower().split("/"), version)
6666

6767
def run_dir(self, task_id: str):
68-
""" Returns the directory for a given task """
68+
"""Returns the directory for a given task"""
6969
path = os.path.join(self.runs_dir, task_id)
7070
mkdir_exists(path)
7171
return path
7272

7373
def project_dir(self, project_id: str):
74-
""" Returns the directory for a given project """
74+
"""Returns the directory for a given project"""
7575
path = os.path.join(self.projects_dir, project_id)
7676
mkdir_exists(path)
7777
return path

datatorch/agent/monitoring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def print_stats(metrics):
2121
class AgentSystemStats(object):
2222
@staticmethod
2323
def initial_stats():
24-
""" Returns stats that do not change over time. """
24+
"""Returns stats that do not change over time."""
2525
# initialize averaging
2626
psutil.cpu_percent()
2727
cpu_freq = psutil.cpu_freq()

datatorch/agent/pipelines/job/job.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def update(self, status: str) -> None:
3535
await self.agent.api.update_job(variables)
3636

3737
async def run(self, variables: Variables):
38-
""" Runs each step of the job. """
38+
"""Runs each step of the job."""
3939
steps = Step.from_dict_list(self.config.get("steps", []), job=self)
4040
await self.update("RUNNING")
4141

datatorch/agent/pipelines/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def from_yaml(cls, path, agent: "Agent" = None):
2222

2323
@classmethod
2424
def from_config(cls, config: Union[str, dict], agent: "Agent" = None):
25-
""" Creates a pipeline from a config file. """
25+
"""Creates a pipeline from a config file."""
2626
if isinstance(config, str):
2727
cf = yaml.load(config, Loader=yaml.FullLoader)
2828
else:
@@ -35,6 +35,6 @@ def __init__(self, config: dict, agent: "Agent" = None):
3535
self.agent = agent
3636

3737
async def run(self, job_config: dict):
38-
""" Runs a job. """
38+
"""Runs a job."""
3939
# await Job(job_config, agent=self.agent).run()
4040
pass

datatorch/agent/pipelines/runner/factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class RunnerCreateError(Exception):
2323
class RunnerFactory(object):
2424
@staticmethod
2525
def create(action, config: dict) -> Runner:
26-
""" Makes runners to 'use' strings found in config.yaml files. """
26+
"""Makes runners to 'use' strings found in config.yaml files."""
2727
use = config.get("using")
2828
if use is None:
2929
raise RunnerCreateError("Action 'use' property not specified.")

datatorch/agent/pipelines/runner/runner.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ async def execute(self) -> Awaitable[dict]:
3030
raise NotImplementedError("This method must be implemented.")
3131

3232
def action_dir(self):
33-
""" Changes the current work directory to the actions directory. """
33+
"""Changes the current work directory to the actions directory."""
3434
os.chdir(self.action.dir)
3535

3636
async def monitor_cmd(self, command: str):
37-
""" Excutes a command and monitors stdout for variables and logging. """
37+
"""Excutes a command and monitors stdout for variables and logging."""
3838
process = await self.run_cmd(command)
3939

4040
async for log in process.stdout:
@@ -48,11 +48,11 @@ async def monitor_cmd(self, command: str):
4848
)
4949

5050
def get(self, key: str, default=None):
51-
""" Gets a string from config and renders template. """
51+
"""Gets a string from config and renders template."""
5252
return self.variables.render(self.config.get(key, default))
5353

5454
def check_for_output(self, string: str) -> bool:
55-
""" Parse output variable from string if valid. """
55+
"""Parse output variable from string if valid."""
5656
# ::varname::value tranlatest to varname = value
5757
result = string.split("::", 2)
5858
if len(result) != 3:
@@ -62,7 +62,7 @@ def check_for_output(self, string: str) -> bool:
6262
return True
6363

6464
async def run_cmd(self, command: str, wait: bool = True):
65-
""" Runs a command using asyncio """
65+
"""Runs a command using asyncio"""
6666
process = await asyncio.create_subprocess_shell(
6767
command,
6868
shell=True,

datatorch/agent/pipelines/step/step.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ async def log_uploader(self):
109109

110110
@property
111111
def api(self):
112-
""" Agent API Client if it exists. """
112+
"""Agent API Client if it exists."""
113113
return self.job and self.job.api
114114

115115
def log(self, message: str):
116-
""" Records a log message. """
116+
"""Records a log message."""
117117
iso_date = datetime.now(timezone.utc).isoformat()[:-9] + "Z"
118118
self.logs.append(dict(createdAt=iso_date, message=message)) # type: ignore
119119
self.logger.info(message)
120120

121121
async def upload_logs(self):
122-
""" Uploads saved logs to webserver. """
122+
"""Uploads saved logs to webserver."""
123123
if self.id and len(self.logs) > 0:
124124
logs = self.logs
125125
self.logs = []

0 commit comments

Comments
 (0)