Skip to content

Commit 51d7709

Browse files
committed
Merge branch 'release/0.16.1'
2 parents c971459 + 609d00f commit 51d7709

File tree

7 files changed

+25
-274
lines changed

7 files changed

+25
-274
lines changed

climetlab/core/caching.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -683,16 +683,19 @@ def cache_file(
683683
),
684684
)
685685

686-
record = register_cache_file(path, owner, args)
687-
if os.path.exists(path):
688-
if callable(force):
689-
owner_data = record["owner_data"]
690-
if owner_data is not None:
691-
owner_data = json.loads(owner_data)
692-
force = force(args, path, owner_data)
693-
694-
if force:
695-
decache_file(path)
686+
try:
687+
record = register_cache_file(path, owner, args)
688+
if os.path.exists(path):
689+
if callable(force):
690+
owner_data = record["owner_data"]
691+
if owner_data is not None:
692+
owner_data = json.loads(owner_data)
693+
force = force(args, path, owner_data)
694+
695+
if force:
696+
decache_file(path)
697+
except Exception as e:
698+
LOG.warning("Cannot register cache file %s: %s", path, e)
696699

697700
if not os.path.exists(path):
698701
lock = path + ".lock"

climetlab/loaders/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ def _load(loader, config, append, print_=print, **kwargs):
350350
print_("Loading input", config.input)
351351

352352
data = cml.load_source("loader", config.input)
353-
if "constant" in config.input:
353+
354+
if "constants" in config.input and config.input.constants:
354355
data = data + cml.load_source("constants", data, config.input.constants)
355356

356357
assert len(data)

climetlab/readers/grib/output.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def f(self, handle):
6262

6363
if path not in self._files:
6464
self._files[path] = open(path, "wb")
65-
return self._files[path]
65+
return self._files[path], path
6666

6767
def write(
6868
self,
@@ -115,7 +115,11 @@ def write(
115115
handle.set(k, v)
116116

117117
handle.set_values(values)
118-
handle.write(self.f(handle))
118+
119+
file, path = self.f(handle)
120+
handle.write(file)
121+
122+
return handle, path
119123

120124
def close(self):
121125
for f in self._files.values():

climetlab/sources/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def __init__(self, date, param, proc, shape):
151151
param=param,
152152
level=None,
153153
levelist=None,
154+
number=None,
154155
)
155156

156157
def to_numpy(self, reshape=True, dtype=None):

climetlab/sources/virtual_directory.py

Lines changed: 0 additions & 259 deletions
This file was deleted.

climetlab/utils/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def __init__(self, config, *args, **kwargs):
135135
if "order_by" in self.output:
136136
self.output.order_by = normalize_order_by(self.output.order_by)
137137

138-
self.input.constants = self.input.get("constants")
138+
if "constants" in self.input:
139+
self.input.constants = self.input["constants"]
139140
self.output.remapping = self.output.get("remapping", {})
140141
self.output.remapping = build_remapping(self.output.remapping)
141142

climetlab/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.15.3
1+
0.16.1

0 commit comments

Comments
 (0)