Skip to content

Commit

Permalink
logging and adding read-only mode to avoid write locks
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Dec 3, 2024
1 parent 47fe110 commit 87527a8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pioreactor/actions/leader/export_experiment_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def export_experiment_data(
available_datasets = load_exportable_datasets()

with zipfile.ZipFile(output, mode="w", compression=zipfile.ZIP_DEFLATED) as zf, closing(
sqlite3.connect(config.get("storage", "database"))
sqlite3.connect(f"file:{config.get('storage', 'database')}?mode=ro", uri=True)
) as con:
con.create_function(
"BASE64", 1, decode_base64
Expand Down Expand Up @@ -226,7 +226,7 @@ def export_experiment_data(
parition_to_writer_map: dict[tuple, Any] = {}

with ExitStack() as stack:
for row in cursor:
for i, row in enumerate(cursor, start=1):
rows_partition = (
row[iloc_experiment] if iloc_experiment is not None else "all_experiments",
row[iloc_unit] if iloc_unit is not None else "all_units",
Expand All @@ -244,6 +244,11 @@ def export_experiment_data(

parition_to_writer_map[rows_partition].writerow(row)

if i % 1000 == 0:
logger.debug(f"Exported {i} rows...")

logger.debug(f"Exported {i} rows from {dataset_name}.")

for filename in filenames:
path_to_file = Path(Path(output).parent / filename)
zf.write(path_to_file, arcname=filename)
Expand Down

0 comments on commit 87527a8

Please sign in to comment.