Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Jul 9, 2024
1 parent f537f57 commit c6fce74
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/anemoi/registry/commands/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ def run_delete_many(self, args):
print(f"Do you really want to delete these {len(cat)} entries? (y/n)", end=" ")
if input("").lower() != "y":
return
count = 0
while cat:
try:
entry = cat[0]
entry.unregister()
count += 1
LOG.info(f"Task {entry.key} deleted.")
except CatalogueEntryNotFound:
LOG.warning(f"Task {entry.key} not found.")
LOG.info(f"{len(cat)} tasks deleted.")
LOG.info(f"{count} tasks deleted.")

def run_take_one(self, args):
cat = TaskCatalogueEntryList(*args.take_one, status="queued", sort=args.sort)
Expand Down
35 changes: 23 additions & 12 deletions src/anemoi/registry/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,29 @@ def to_str(self, long):
status = v.pop("status")
progress = v.pop("progress", "")
action = v.pop("action", "")
if not long:
if "worker" in v:
v["worker"] = v["worker"].get("host")
content = " ".join(f"{k}={v}" for k, v in v.items())
rows.append(
[action, when(created, use_utc=True), when(updated, use_utc=True), status, progress, content, uuid]
)
return table(
rows,
["Action", "Created", "Updated", "Status", "%", "Details", "UUID"],
["<", "<", "<", "<", "<", "<", "<"],
)
source = v.pop("source", "")
destination = v.pop("destination", "")
dataset = v.pop("dataset", "")
row = [
when(created, use_utc=True),
when(updated, use_utc=True),
status,
action,
source,
destination,
dataset,
progress,
uuid,
]
rows.append(row)
if long:
content = " ".join(f"{k}={v}" for k, v in v.items())
row.append(content)
cols = ["Created", "Updated", "Status", "Action", "Src", "Dest", "Dataset", "%", "UUID"]
if long:
cols.append("More")

return table(rows, cols, "<" * len(cols))


class TaskCatalogueEntry(CatalogueEntry):
Expand Down
2 changes: 1 addition & 1 deletion src/anemoi/registry/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def get_source_path():
source_path = source_path + "/" if not source_path.endswith("/") else source_path

if target_path.startswith("s3://"):
# untested
LOG.warning("Uploading to S3 is experimental and has not been tested yet.")
download(source_path, target_path, resume=True, threads=self.threads)
return
else:
Expand Down

0 comments on commit c6fce74

Please sign in to comment.