Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/myna/core/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]
Expand Down
4 changes: 2 additions & 2 deletions src/myna/core/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
26 changes: 26 additions & 0 deletions src/myna/core/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
gknapp1 marked this conversation as resolved.

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 []
11 changes: 4 additions & 7 deletions src/myna/core/workflow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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}")
Comment thread
gknapp1 marked this conversation as resolved.
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
Expand Down
3 changes: 3 additions & 0 deletions src/myna/database/database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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