Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
add cleanup of tmp directory when building zarr
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Feb 19, 2024
1 parent 4a60427 commit 7e3d9d1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions ecml_tools/create/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ def size(self):
loader = SizeLoader.from_dataset(path=self.path, print=self.print)
loader.add_total_size()

def cleanup(self):
from .loaders import CleanupLoader

loader = CleanupLoader.from_dataset(
path=self.path,
print=self.print,
statistics_tmp=self.statistics_tmp,
)
loader.run()


def patch(self, **kwargs):
from .patch import apply_patch

Expand All @@ -112,6 +123,7 @@ def create(self):
self.init()
self.load()
self.finalise()
self.cleanup()

def _cache_context(self):
from .utils import cache_context
Expand Down
5 changes: 5 additions & 0 deletions ecml_tools/create/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,8 @@ def add_total_size(self):
print(f"Total number of files: {n}")

self.update_metadata(total_size=size, total_number_of_files=n)

class CleanupLoader(Loader):
def run(self):
self.statistics_registry.delete()
self.registry.clean()
2 changes: 1 addition & 1 deletion tests/create-join.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ input:
# accumulation_period: 6h

- constants:
<<: *mars_request
template: ${input.join.0.mars}
param:
- cos_latitude

Expand Down
2 changes: 1 addition & 1 deletion tests/create-pipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ input:
param: [cp, tp]

- constants:
<<: *mars_request
template: ${input.join.0.mars}
param:
- cos_latitude

Expand Down

0 comments on commit 7e3d9d1

Please sign in to comment.