Skip to content

Commit

Permalink
Change:
Browse files Browse the repository at this point in the history
 - Removed DATA_PATH environment variable
 - Updated CSV path handling:
  - For file copies, we now load the absolute path.
  - For sockets, the path is left empty.
  • Loading branch information
Kostas Filippopolitis committed Jul 9, 2024
1 parent 2ffc048 commit 82c1f9b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mipdb/databases/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Dataset(Base):
code = sql.Column(sql.String, nullable=False)
label = sql.Column(sql.String, nullable=False)
status = sql.Column(sql.String, nullable=False)
csv_path = sql.Column(sql.String, nullable=False)
csv_path = sql.Column(sql.String, nullable=True)
properties = sql.Column(sql.JSON, nullable=True)


Expand Down
6 changes: 2 additions & 4 deletions mipdb/usecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,14 @@ def execute(
cdes = metadata_table.table
dataset_enumerations = get_dataset_enums(cdes)
sql_type_per_column = get_sql_type_per_column(cdes)
# In case the DATA_PATH is empty it will return the whole path.
relative_csv_path = csv_path.split(os.getenv("DATA_PATH"))[-1]

with self.monetdb.begin() as monetdb_conn:
imported_datasets = (
self.import_csv_with_volume(
csv_path, sql_type_per_column, data_model, monetdb_conn
)
if copy_from_file
else self._import_csv(relative_csv_path, data_model, monetdb_conn)
else self._import_csv(csv_path, data_model, monetdb_conn)
)

existing_datasets = DatasetsTable().get_dataset_codes(
Expand All @@ -213,7 +211,7 @@ def execute(
dataset_id=dataset_id,
code=dataset,
label=dataset_enumerations[dataset],
csv_path=relative_csv_path,
csv_path=csv_path if copy_from_file else None,
status="ENABLED",
properties=None,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_usecases.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def test_add_dataset(sqlite_db, monetdb, data_model_metadata):
AddDataModel(sqlite_db, monetdb).execute(data_model_metadata)
# Test success
ImportCSV(sqlite_db, monetdb).execute(
csv_path=DATASET_FILE,
copy_from_file=False,
csv_path=ABSOLUTE_PATH_DATASET_FILE,
copy_from_file=True,
data_model_code="data_model",
data_model_version="1.0",
)
Expand Down

0 comments on commit 82c1f9b

Please sign in to comment.