diff --git a/src/myna/core/components/component.py b/src/myna/core/components/component.py index a583c10e..1cf12ec7 100644 --- a/src/myna/core/components/component.py +++ b/src/myna/core/components/component.py @@ -200,7 +200,7 @@ def get_files_from_template(self, template, abspath=True): # Get build name input_dir = os.path.abspath(os.path.dirname(os.environ["MYNA_INPUT"])) - build = self.data["build"]["name"] + build = nested_get(self.data, ["build", "name"], "myna_output") # Get all other names that are set by the component vars = self.types[1:] diff --git a/src/myna/core/db/__init__.py b/src/myna/core/db/__init__.py index de2cd3b0..72916abf 100644 --- a/src/myna/core/db/__init__.py +++ b/src/myna/core/db/__init__.py @@ -8,6 +8,6 @@ # """Define the requirements and behavior of Myna databases.""" -from .database import Database +from .database import Database, NoDatabase -__all__ = ["Database"] +__all__ = ["Database", "NoDatabase"] diff --git a/src/myna/core/db/database.py b/src/myna/core/db/database.py index 394c35f0..d29582b4 100644 --- a/src/myna/core/db/database.py +++ b/src/myna/core/db/database.py @@ -82,3 +82,29 @@ def write_segment_sync_metadata( sync_dict[segment_type_key][segment_key]["synced_by"] = os.getlogin() with open(sync_metadata_file, "w", encoding="utf-8") as mf: yaml.safe_dump(sync_dict, mf) + + +class NoDatabase(Database): + """Non-existent database used for tasks that don't actually require build data""" + + def __init__(self): + super().__init__() + self.build_segmentation_type = "layer" + + def set_path(self, path): + pass + + def exists(self) -> bool: + return True + + def load(self, metadata_type, **kwargs): + """Returns None since there is no database to load from.""" + return None + + def get_cui_info(self): + """Returns 'N/A' since there is no database.""" + return "N/A" + + def sync(self, component_type, step_types, output_class, files): + """Returns an empty list since there is no database to sync to.""" + return [] diff --git a/src/myna/core/workflow/config.py b/src/myna/core/workflow/config.py index efadc8c5..32b0c7e8 100644 --- a/src/myna/core/workflow/config.py +++ b/src/myna/core/workflow/config.py @@ -83,8 +83,10 @@ def config(input_file, output_file=None, show_avail=False, overwrite=False): settings = load_input(input_file) # Check build directory contains the expected metadata folder - build_path = settings["data"]["build"]["path"] - datatype = database.return_datatype_class(settings["data"]["build"]["datatype"]) + build_path = nested_get(settings, ["data", "build", "path"]) + datatype = database.return_datatype_class( + nested_get(settings, ["data", "build", "datatype"], "None") + ) datatype.set_path(build_path) if not datatype.exists(): print(f"ERROR: Could not find valid {datatype} in" + f" {build_path}") @@ -131,11 +133,6 @@ def config(input_file, output_file=None, show_avail=False, overwrite=False): all_parts.extend(build_region_parts) all_parts = list(set(all_parts)) - # Check that some amount of parts were specified - if len(all_parts) < 1: - print(f"ERROR: No parts specified in {input_file}") - raise ValueError - # Get list of all segments in build parts and build_region parts # Possible options for types segments are: # - datatype.build_segmentation_type == "layer": uses layers diff --git a/src/myna/database/database_types.py b/src/myna/database/database_types.py index 72fe9c03..d140c9a7 100644 --- a/src/myna/database/database_types.py +++ b/src/myna/database/database_types.py @@ -13,6 +13,7 @@ from myna.database.nist_ambench_2022 import AMBench2022 from myna.database.myna_json import MynaJSON from myna.database.pelican import Pelican +from myna.core.db import NoDatabase def return_datatype_class(datatype_str): @@ -51,6 +52,8 @@ def remove_text_format(text): return MynaJSON() elif remove_text_format(datatype_str) in ["pelican"]: return Pelican() + elif remove_text_format(datatype_str) in ["none"]: + return NoDatabase() else: print(f"Error: {datatype_str} does not correspond to any implemented database") raise NotImplementedError