Skip to content

Commit

Permalink
qa
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Dec 2, 2024
1 parent a07ec2a commit 006b6c9
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions src/anemoi/registry/workers/update_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
# nor does it submit to any jurisdiction.


import datetime
import logging
import os
from copy import deepcopy

from anemoi.registry.entry.dataset import DatasetCatalogueEntry

Expand All @@ -20,50 +18,6 @@
LOG = logging.getLogger(__name__)


class Progress:
latest = None

def __init__(self, task, frequency=60):
self.task = task
self.frequency = frequency
self.first_progress = None
self.first_transfer_progress = None
self.previous_progress = None

def __call__(self, number_of_files, total_size, total_transferred, transfering, **kwargs):
now = datetime.datetime.utcnow()

if self.latest is not None and (now - self.latest).seconds < self.frequency:
# already updated recently
return
self.latest = now

timestamp = now.isoformat()

progress = dict(
number_of_files=number_of_files,
total_size=total_size,
total_transferred=total_transferred,
transfering=transfering,
timestamp=timestamp,
percentage=100 * total_transferred / total_size if total_size and transfering else 0,
**kwargs,
)

if self.first_progress is None:
self.first_progress = progress
if self.first_transfer_progress is None and transfering:
self.first_transfer_progress = progress

p = deepcopy(progress)
p["first_progress"] = self.first_progress
p["first_transfer_progress"] = self.first_transfer_progress
p["previous_progress"] = self.previous_progress
self.task.set_progress(p)

self.previous_progress = progress


class UpdateDatasetWorker(Worker):
"""Patch datsets from the catalogue"""

Expand Down

0 comments on commit 006b6c9

Please sign in to comment.