Skip to content

Commit

Permalink
Added a new field on system table for datasets that stores the path o…
Browse files Browse the repository at this point in the history
…f the csv that contains the specific dataset.
  • Loading branch information
KFilippopolitis committed Jun 10, 2024
1 parent 891a584 commit db54908
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions mipdb/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def __init__(self, schema):
sql.Column("code", SQLTYPES.STRING, nullable=False),
sql.Column("label", SQLTYPES.STRING),
sql.Column("status", SQLTYPES.STRING, nullable=False),
sql.Column("csv_path", SQLTYPES.STRING, nullable=False),
sql.Column("properties", SQLTYPES.JSON),
)

Expand Down
1 change: 1 addition & 0 deletions mipdb/usecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def execute(
dataset_id=dataset_id,
code=dataset,
label=dataset_enumerations[dataset],
csv_path=csv_path,
status="ENABLED",
)
datasets_table.insert_values(values, conn)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mipdb"
version = "2.4.7"
version = "2.4.8"
description = ""
authors = ["Your Name <[email protected]>"]

Expand Down
4 changes: 2 additions & 2 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def test_get_dataset_id_duplication_error(db):

db.execute(
sql.text(
'INSERT INTO "mipdb_metadata".datasets (dataset_id, data_model_id, code, status)'
"VALUES (2, 1, 'dataset', 'DISABLED')"
'INSERT INTO "mipdb_metadata".datasets (dataset_id, data_model_id, code, csv_path, status)'
"VALUES (2, 1, 'dataset', '/opt/data/data_model/dataset.csv', 'DISABLED')"
)
)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_usecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ def test_add_dataset(db, data_model_metadata):
data_model_code="data_model",
data_model_version="1.0",
)
(code, csv_path), *_ = db.execute(f"SELECT code, csv_path FROM mipdb_metadata.datasets").fetchall()
assert "dataset.csv" in csv_path
res = db.execute('SELECT * FROM "data_model:1.0".primary_data').fetchall()
assert res != []

Expand Down

0 comments on commit db54908

Please sign in to comment.