Skip to content

Commit

Permalink
renamed front-end and back-end to back-read and back-write in core
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedant P Iyer committed Oct 31, 2024
1 parent bb5db1a commit 04ec89b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 5 additions & 9 deletions dsi/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Terminal():
An instantiated Terminal is the DSI human/machine interface.
Terminals are a home for Plugins and an interface for Backends. Backends may be
front-ends or back-ends. Plugins may be Writers or readers. See documentation
back-reads or back-writes. Plugins may be Writers or readers. See documentation
for more information.
"""
BACKEND_PREFIX = ['dsi.backends']
Expand All @@ -28,7 +28,7 @@ class Terminal():
VALID_BACKENDS = ['Gufi', 'Sqlite', 'Parquet']
VALID_MODULES = VALID_PLUGINS + VALID_BACKENDS
VALID_MODULE_FUNCTIONS = {'plugin': [
'writer', 'reader'], 'backend': ['front-end', 'back-end']}
'writer', 'reader'], 'backend': ['back-read', 'back-write']}
VALID_ARTIFACT_INTERACTION_TYPES = ['get', 'set', 'put', 'inspect']

def __init__(self, debug_flag = False):
Expand Down Expand Up @@ -235,7 +235,7 @@ def artifact_handler(self, interaction_type, query = None, **kwargs):
Store or retrieve using all loaded DSI Backends with storage functionality.
A DSI Core Terminal may load zero or more Backends with storage functionality.
Calling artifact_handler will execute all back-end functionality currently loaded, given
Calling artifact_handler will execute all back-write functionality currently loaded, given
the provided ``interaction_type``.
"""
if interaction_type not in self.VALID_ARTIFACT_INTERACTION_TYPES:
Expand All @@ -246,7 +246,7 @@ def artifact_handler(self, interaction_type, query = None, **kwargs):
# Perform artifact movement first, because inspect implementation may rely on
# self.active_metadata or some stored artifact.
selected_function_modules = dict(
(k, self.active_modules[k]) for k in (['back-end']))
(k, self.active_modules[k]) for k in (['back-write']))
for module_type, objs in selected_function_modules.items():
for obj in objs:
self.logger.info(f"-------------------------------------")
Expand All @@ -268,11 +268,7 @@ def artifact_handler(self, interaction_type, query = None, **kwargs):
operation_success = True
end = datetime.now()
self.logger.info(f"Runtime: {end-start}")
if interaction_type == 'inspect':
for module_type, objs in selected_function_modules.items():
for obj in objs:
self.logger.info(f"-------------------------------------")
self.logger.info(obj.__class__.__name__ + f" {module_type} - {interaction_type} the data")
elif interaction_type == 'inspect':
start = datetime.now()
obj.put_artifacts(
collection=self.active_metadata, **kwargs)
Expand Down
10 changes: 5 additions & 5 deletions examples/coreterminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
# print(a.active_metadata)
a.load_module('plugin', 'TOML', 'reader', filenames=["data/results.toml"], target_table_prefix = "results")
# print(a.active_metadata)
a.load_module('backend','Sqlite','back-end', filename='data/data.db')
#a.load_module('backend','Sqlite','back-end', filename='data/data2.db')
# a.load_module('backend','Parquet','back-end',filename='./data/bueno.pq')
a.load_module('backend','Sqlite','back-write', filename='data/data.db')
#a.load_module('backend','Sqlite','back-write', filename='data/data2.db')
# a.load_module('backend','Parquet','back-write',filename='./data/bueno.pq')

#a.load_module('plugin', "Table_Plot", "writer", table_name = "schema_physics", filename = "schema_physics")

Expand All @@ -35,12 +35,12 @@
# {'writer': [<dsi.plugins.env.Hostname object at 0x7f21232474d0>],
# 'reader': [<dsi.plugins.env.Bueno object at 0x7f2123247410>],
# 'front-end': [],
# 'back-end': []}
# 'back-write': []}


# Example use
# a.load_module('plugin','Bueno','reader',filenames='data/bueno1.data')
# a.load_module('backend','Sqlite','back-end',filename='data/bueno.db')
# a.load_module('backend','Sqlite','back-write',filename='data/bueno.db')
# a.transload()
# a.artifact_handler(interaction_type='put')
data = a.artifact_handler(interaction_type='get', query = "SELECT * FROM sqlite_master WHERE type='table';")#, isVerbose = True)
Expand Down

0 comments on commit 04ec89b

Please sign in to comment.