Skip to content

Commit

Permalink
Fix issue when changing the template mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aymgal committed Jul 18, 2023
1 parent dd4d185 commit cb469d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions coolest/template/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ def dump_simple(self, exclude_keys=None):
List of class attributes that should not be included
in the JSON file, by default None
"""
if exclude_keys is None and hasattr(self.obj, 'exclude_keys'):
if exclude_keys is None:
exclude_keys = self.obj.exclude_keys
json_path = self.path + '.json'
result = jsonpickle.encode(self.obj, indent=self.indent)
with open(json_path, 'w') as f:
f.write(self.obj.to_JSON(indent=self.indent, exclude_keys=exclude_keys))

Expand Down Expand Up @@ -285,6 +284,9 @@ def _update_parameters_values(self, entity_in, entity_out, model_type):

for name, values in profile['parameters'].items():

# pop the id as this was already set at instantiation
_ = values.pop('id', None)

# pixelated profiles, for now only one value given (point estimate)
if 'Grid' in profile['type']:
self._update_grid_parameter(profile_out, name, values)
Expand Down
11 changes: 6 additions & 5 deletions coolest/template/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ def __init__(self,
metadata = {}
self.meta = metadata

@property
def exclude_keys(self):
if self.mode == 'MOCK':
self.exclude_keys = MOCK_EXCLUDE_KEYS
return MOCK_EXCLUDE_KEYS
elif self.mode == 'MAP':
self.exclude_keys = MAP_EXCLUDE_KEYS
return MAP_EXCLUDE_KEYS
elif self.mode == 'DOC':
self.exclude_keys = DOC_EXCLUDE_KEYS
return DOC_EXCLUDE_KEYS
else:
self.exclude_keys = []
self.exclude_keys += ['exclude_keys']
return []

0 comments on commit cb469d1

Please sign in to comment.