Skip to content

Commit

Permalink
Merge branch 'release/0.16.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
floriankrb committed Aug 11, 2023
2 parents c971459 + 609d00f commit 51d7709
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 274 deletions.
23 changes: 13 additions & 10 deletions climetlab/core/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,16 +683,19 @@ def cache_file(
),
)

record = register_cache_file(path, owner, args)
if os.path.exists(path):
if callable(force):
owner_data = record["owner_data"]
if owner_data is not None:
owner_data = json.loads(owner_data)
force = force(args, path, owner_data)

if force:
decache_file(path)
try:
record = register_cache_file(path, owner, args)
if os.path.exists(path):
if callable(force):
owner_data = record["owner_data"]
if owner_data is not None:
owner_data = json.loads(owner_data)
force = force(args, path, owner_data)

if force:
decache_file(path)
except Exception as e:
LOG.warning("Cannot register cache file %s: %s", path, e)

if not os.path.exists(path):
lock = path + ".lock"
Expand Down
3 changes: 2 additions & 1 deletion climetlab/loaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ def _load(loader, config, append, print_=print, **kwargs):
print_("Loading input", config.input)

data = cml.load_source("loader", config.input)
if "constant" in config.input:

if "constants" in config.input and config.input.constants:
data = data + cml.load_source("constants", data, config.input.constants)

assert len(data)
Expand Down
8 changes: 6 additions & 2 deletions climetlab/readers/grib/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def f(self, handle):

if path not in self._files:
self._files[path] = open(path, "wb")
return self._files[path]
return self._files[path], path

def write(
self,
Expand Down Expand Up @@ -115,7 +115,11 @@ def write(
handle.set(k, v)

handle.set_values(values)
handle.write(self.f(handle))

file, path = self.f(handle)
handle.write(file)

return handle, path

def close(self):
for f in self._files.values():
Expand Down
1 change: 1 addition & 0 deletions climetlab/sources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def __init__(self, date, param, proc, shape):
param=param,
level=None,
levelist=None,
number=None,
)

def to_numpy(self, reshape=True, dtype=None):
Expand Down
259 changes: 0 additions & 259 deletions climetlab/sources/virtual_directory.py

This file was deleted.

3 changes: 2 additions & 1 deletion climetlab/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def __init__(self, config, *args, **kwargs):
if "order_by" in self.output:
self.output.order_by = normalize_order_by(self.output.order_by)

self.input.constants = self.input.get("constants")
if "constants" in self.input:
self.input.constants = self.input["constants"]
self.output.remapping = self.output.get("remapping", {})
self.output.remapping = build_remapping(self.output.remapping)

Expand Down
2 changes: 1 addition & 1 deletion climetlab/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.15.3
0.16.1

0 comments on commit 51d7709

Please sign in to comment.