IAP GITLAB

Skip to content
Snippets Groups Projects

Improved handling of corsika.Library

Merged Alan Coleman requested to merge 718-make-io-library-aware-of-expected-content into master
All threads resolved!
1 file
+ 17
6
Compare changes
  • Side-by-side
  • Inline
@@ -133,7 +133,7 @@ class Library(object):
@@ -133,7 +133,7 @@ class Library(object):
"""
"""
return self.__load_yaml(path, "config.yaml")
return Library.__load_yaml(path, "config.yaml")
@staticmethod
@staticmethod
def load_summary(path: str) -> Optional[Dict[str, Any]]:
def load_summary(path: str) -> Optional[Dict[str, Any]]:
@@ -153,7 +153,7 @@ class Library(object):
@@ -153,7 +153,7 @@ class Library(object):
"""
"""
return self.__load_yaml(path, "summary.yaml")
return Library.__load_yaml(path, "summary.yaml")
@staticmethod
@staticmethod
def __valid_library(path: str) -> bool:
def __valid_library(path: str) -> bool:
@@ -185,7 +185,9 @@ class Library(object):
@@ -185,7 +185,9 @@ class Library(object):
return config["creator"] == "CORSIKA8"
return config["creator"] == "CORSIKA8"
@staticmethod
@staticmethod
def __build_outputs(path: str, dirs: Union[list, None]) -> Dict[str, outputs.Output]:
def __build_outputs(
 
path: str, dirs: Union[list, None]
 
) -> Dict[str, outputs.Output]:
"""
"""
Build the outputs contained in this library.
Build the outputs contained in this library.
@@ -233,7 +235,10 @@ class Library(object):
@@ -233,7 +235,10 @@ class Library(object):
# if `out_type` was None, this is an invalid output
# if `out_type` was None, this is an invalid output
if out_type is None or name is None:
if out_type is None or name is None:
msg = f"'{subdir}' does not contain a valid config." "Missing 'type' or 'name' keyword."
msg = (
 
f"'{subdir}' does not contain a valid config."
 
"Missing 'type' or 'name' keyword."
 
)
logging.getLogger("corsika").warning(msg)
logging.getLogger("corsika").warning(msg)
continue # skip to the next output, don't error
continue # skip to the next output, don't error
@@ -245,13 +250,19 @@ class Library(object):
@@ -245,13 +250,19 @@ class Library(object):
# check if the read failed
# check if the read failed
if not component.is_good():
if not component.is_good():
msg = f"'{name}' encountered an error while reading. " "This process will be not be loaded."
msg = (
 
f"'{name}' encountered an error while reading. "
 
"This process will be not be loaded."
 
)
logging.getLogger("corsika").warning(msg)
logging.getLogger("corsika").warning(msg)
else:
else:
components[name] = component
components[name] = component
except AttributeError as e:
except AttributeError as e:
msg = f"Unable to instantiate an instance of '{out_type}' " f"for a process called '{name}'. Skipping '{subdir}'"
msg = (
 
f"Unable to instantiate an instance of '{out_type}' "
 
f"for a process called '{name}'. Skipping '{subdir}'"
 
)
logging.getLogger("corsika").warning(msg)
logging.getLogger("corsika").warning(msg)
logging.getLogger("corsika").warning(e)
logging.getLogger("corsika").warning(e)
continue # skip to the next output, don't error
continue # skip to the next output, don't error
Loading