adopt ruff as the replacement for python black (#332)
This commit is contained in:
@@ -17,7 +17,11 @@ class ArtifactManager:
|
||||
upload_aiotasks_map: dict[str, list[asyncio.Task[None]]] = defaultdict(list)
|
||||
|
||||
async def create_artifact(
|
||||
self, step: Step, artifact_type: ArtifactType, data: bytes | None = None, path: str | None = None
|
||||
self,
|
||||
step: Step,
|
||||
artifact_type: ArtifactType,
|
||||
data: bytes | None = None,
|
||||
path: str | None = None,
|
||||
) -> str:
|
||||
# TODO (kerem): Which is better?
|
||||
# current: (disadvantage: we create the artifact_id UUID here)
|
||||
@@ -87,7 +91,10 @@ class ArtifactManager:
|
||||
duration=time.time() - st,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
LOG.error(f"Timeout (30s) while waiting for upload tasks for task_id={task_id}", task_id=task_id)
|
||||
LOG.error(
|
||||
f"Timeout (30s) while waiting for upload tasks for task_id={task_id}",
|
||||
task_id=task_id,
|
||||
)
|
||||
|
||||
del self.upload_aiotasks_map[task_id]
|
||||
|
||||
@@ -109,7 +116,10 @@ class ArtifactManager:
|
||||
duration=time.time() - st,
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
LOG.error(f"Timeout (30s) while waiting for upload tasks for task_ids={task_ids}", task_ids=task_ids)
|
||||
LOG.error(
|
||||
f"Timeout (30s) while waiting for upload tasks for task_ids={task_ids}",
|
||||
task_ids=task_ids,
|
||||
)
|
||||
|
||||
for task_id in task_ids:
|
||||
del self.upload_aiotasks_map[task_id]
|
||||
|
||||
@@ -28,7 +28,11 @@ class LocalStorage(BaseStorage):
|
||||
with open(file_path, "wb") as f:
|
||||
f.write(data)
|
||||
except Exception:
|
||||
LOG.exception("Failed to store artifact locally.", file_path=file_path, artifact=artifact)
|
||||
LOG.exception(
|
||||
"Failed to store artifact locally.",
|
||||
file_path=file_path,
|
||||
artifact=artifact,
|
||||
)
|
||||
|
||||
async def store_artifact_from_path(self, artifact: Artifact, path: str) -> None:
|
||||
file_path = None
|
||||
@@ -37,7 +41,11 @@ class LocalStorage(BaseStorage):
|
||||
self._create_directories_if_not_exists(file_path)
|
||||
Path(path).replace(file_path)
|
||||
except Exception:
|
||||
LOG.exception("Failed to store artifact locally.", file_path=file_path, artifact=artifact)
|
||||
LOG.exception(
|
||||
"Failed to store artifact locally.",
|
||||
file_path=file_path,
|
||||
artifact=artifact,
|
||||
)
|
||||
|
||||
async def retrieve_artifact(self, artifact: Artifact) -> bytes | None:
|
||||
file_path = None
|
||||
@@ -46,7 +54,11 @@ class LocalStorage(BaseStorage):
|
||||
with open(file_path, "rb") as f:
|
||||
return f.read()
|
||||
except Exception:
|
||||
LOG.exception("Failed to retrieve local artifact.", file_path=file_path, artifact=artifact)
|
||||
LOG.exception(
|
||||
"Failed to retrieve local artifact.",
|
||||
file_path=file_path,
|
||||
artifact=artifact,
|
||||
)
|
||||
return None
|
||||
|
||||
async def get_share_link(self, artifact: Artifact) -> str:
|
||||
|
||||
Reference in New Issue
Block a user