Skip to content

Commit 6bce99f

Browse files
committed
updated gufi and parquet backends to use new artifact handler names
1 parent e219a08 commit 6bce99f

File tree

4 files changed

+42
-25
lines changed

4 files changed

+42
-25
lines changed

dsi/backends/gufi.py

+20-16
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,26 @@ class Gufi(Filesystem):
1515
'''
1616
GUFI Datastore
1717
'''
18-
1918
prefix = ""
2019
index = ""
2120
dbfile = ""
2221
table = ""
2322
column = ""
2423
isVerbose = False
2524

26-
"""
27-
prefix: prefix to GUFI commands
28-
index: directory with GUFI indexes
29-
dbfile: sqlite db file from DSI
30-
table: table name from the DSI db we want to join on
31-
column: column name from the DSI db to join on
32-
"""
33-
3425
def __init__(self, prefix, index, dbfile, table, column, verbose=False):
3526
'''
36-
prefix: prefix to GUFI commands
37-
index: directory with GUFI indexes
38-
dbfile: sqlite db file from DSI
39-
table: table name from the DSI db we want to join on
40-
column: column name from the DSI db to join on
41-
verbose: print debugging statements or not
27+
`prefix`: prefix to GUFI commands
28+
29+
`index`: directory with GUFI indexes
30+
31+
`dbfile`: sqlite db file from DSI
32+
33+
`table`: table name from the DSI db we want to join on
34+
35+
`column`: column name from the DSI db to join on
36+
37+
`verbose`: print debugging statements or not
4238
'''
4339

4440
super().__init__(dbfile)
@@ -55,8 +51,12 @@ def __init__(self, prefix, index, dbfile, table, column, verbose=False):
5551

5652
self.isVerbose = verbose
5753

58-
# Query GUFI and DSI db
54+
# OLD NAME OF query_artifacts(). TO BE DEPRECATED IN FUTURE DSI RELEASE
5955
def get_artifacts(self, query):
56+
return self.query_artifacts(query)
57+
58+
# Query GUFI and DSI db
59+
def query_artifacts(self, query):
6060
'''
6161
Retrieves GUFI's metadata joined with a dsi database
6262
query: an sql query into the dsi_entries table
@@ -68,7 +68,11 @@ def get_artifacts(self, query):
6868

6969
return resout
7070

71+
# OLD NAME OF ingest_artifacts(). TO BE DEPRECATED IN FUTURE DSI RELEASE
7172
def put_artifacts(self, query):
73+
return self.ingest_artifacts(query)
74+
75+
def ingest_artifacts(self, query):
7276
pass
7377

7478
# Runs the gufi query command

dsi/backends/parquet.py

+15-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,22 @@ def __init__(self, filename, **kwargs):
2020
except KeyError:
2121
self.compression = None
2222

23+
# OLD NAME OF query_artifacts(). TO BE DEPRECATED IN FUTURE DSI RELEASE
2324
def get_artifacts(self):
24-
"""Get Parquet data from filename."""
25+
return self.query_artifacts()
26+
27+
def query_artifacts(self):
28+
"""Query Parquet data from filename."""
2529
table = pq.read_table(self.filename)
2630
resout = table.to_pydict()
2731
return resout
2832

33+
# OLD NAME OF ingest_artifacts(). TO BE DEPRECATED IN FUTURE DSI RELEASE
2934
def put_artifacts(self, collection):
30-
"""Put artifacts into file at filename path."""
35+
return self.ingest_artifacts(collection)
36+
37+
def ingest_artifacts(self, collection):
38+
"""Ingest artifacts into file at filename path."""
3139
table = pa.table(collection)
3240
pq.write_table(table, self.filename, compression=self.compression)
3341

@@ -43,7 +51,12 @@ def get_cmd_output(cmd: list) -> str:
4351
raise Exception(proc.stderr)
4452
return proc.stdout.strip().decode("utf-8")
4553

54+
# OLD NAME OF notebook(). TO BE DEPRECATED IN FUTURE DSI RELEASE
4655
def inspect_artifacts(self, collection, interactive=False):
56+
return self.notebook(collection, interactive)
57+
58+
def notebook(self, collection, interactive=False):
59+
"""Generate Jupyter notebook of Parquet data from filename."""
4760
import nbconvert as nbc
4861
import nbformat as nbf
4962

dsi/backends/tests/test_gufi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def test_artifact_query():
1111
column = "sample_col"
1212
store = Gufi(prefix, index, dbpath, table, column, isVerbose)
1313
sqlstr = "select * from dsi_entries"
14-
rows = store.get_artifacts(sqlstr)
14+
rows = store.query_artifacts(sqlstr)
1515
store.close()
1616
assert len(rows) > 0

dsi/backends/tests/test_parquet.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ def get_git_root(path):
1111
git_root = git_repo.git.rev_parse("--show-toplevel")
1212
return (git_root)
1313

14-
def test_get_artifacts():
14+
def test_query_artifacts():
1515
a = Parquet(filename='/'.join([get_git_root('.'), 'dsi/data/wildfiredata.pq']))
16-
b = a.get_artifacts()
16+
b = a.query_artifacts()
1717
cnt = 0
1818
for key in b:
1919
cnt = cnt + 1
2020
assert 4 == len(b[key])
2121
assert 11 == cnt
2222

23-
def test_inspect_artifact():
23+
def test_notebook():
2424
a = Parquet(filename='/'.join([get_git_root('.'), 'dsi/data/wildfiredata.pq']))
25-
b = a.get_artifacts()
26-
a.inspect_artifacts(b)
27-
# No error on inspect_artifact return implies success
25+
b = a.query_artifacts()
26+
a.notebook(b)
27+
# No error on notebook return implies success
2828
assert True
2929

0 commit comments

Comments
 (0)