Skip to content

Commit

Permalink
FIX: bug in backing up journal file locally.
Browse files Browse the repository at this point in the history
  • Loading branch information
tcpan committed Oct 28, 2024
1 parent 6bda606 commit 197d359
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
5 changes: 3 additions & 2 deletions chorus_upload/upload_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,9 @@ def upload_files(src_path : FileSystemHelper, dest_path : FileSystemHelper,
# backup_journal(databasename, suffix=upload_ver_str)
# just copy the journal file to the dated dest path as a backup, and locally sa well
journal_path.copy_file_to(journal_fn, dated_dest_path)
journal_path.copy_file_to("_".join([journal_fn, upload_ver_str]), src_path)

dest_fn = src_path.root.joinpath("_".join([journal_fn, upload_ver_str]))
journal_path.copy_file_to(journal_fn, dest_fn)

del perf
return upload_ver_str, remaining

Expand Down
58 changes: 29 additions & 29 deletions tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
rm journal.db
rm journal_test.db

# test configuration
# phase 1: with firstsnapshot data
Expand Down Expand Up @@ -45,21 +45,21 @@ container="test"
sas=""

# clean up
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "journal.db*"
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "journal_test.db*"
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "2024*"


# test configuration
echo TEST phase 1: with firstsnapshot data
rm journal.db
rm journal_test.db
config=tests/configlocal.toml
azcli=TestData/azcli1.sh
azcli2=TestData/azcli2.sh

echo TEST update journal
echo python chorus_upload -v -c ${config} journal update --modalities OMOP,Waveforms
python chorus_upload -v -c ${config} journal update --modalities OMOP,Waveforms
cp journal.db TestData/journal1.1.db
cp journal_test.db TestData/journal1.1.db

echo TEST generate file list
echo python chorus_upload -v -c ${config} file list --modalities OMOP,Waveforms --output-file ${azcli} --output-type azcli --max-num-files 15
Expand All @@ -73,11 +73,11 @@ eval ${azcli}

# database should have partially uploaded data.
# wait for user input
cp journal.db TestData/journal1.2.db
cp journal_test.db TestData/journal1.2.db

echo python chorus_upload -v -c ${config} journal update --modalities Images
python chorus_upload -v -c ${config} journal update --modalities Images
cp journal.db TestData/journal1.3.db
cp journal_test.db TestData/journal1.3.db


echo TEST generate file list again
Expand All @@ -89,24 +89,24 @@ echo TEST with local journal and upload to central azcli - AMENDING
chmod a+x ${azcli2}
# run the azcli script
eval ${azcli2}
cp journal.db TestData/journal1.4.db
cp journal_test.db TestData/journal1.4.db

echo TEST with local journal and upload to central built in - AMENDING
echo python chorus_upload -v -c ${config} file upload --modalities OMOP,Waveforms --max-num-files 15
python chorus_upload -v -c ${config} file upload --modalities OMOP,Waveforms --max-num-files 15
cp journal.db TestData/journal1.5.db
cp journal_test.db TestData/journal1.5.db


echo TEST update journal with second snapshot data
echo python chorus_upload -v -c ${config} journal update --modalities Images
python chorus_upload -v -c ${config} journal update --modalities Images
cp journal.db TestData/journal1.6.db
cp journal_test.db TestData/journal1.6.db


echo TEST with local journal and upload to central using built in
echo python chorus_upload -v -c ${config} file upload --modalities Images
python chorus_upload -v -c ${config} file upload --modalities Images
cp journal.db TestData/journal1.7.db
cp journal_test.db TestData/journal1.7.db


echo TEST verify the version
Expand All @@ -115,8 +115,8 @@ python chorus_upload -v -c ${config} file verify --modalities OMOP

# ========================
echo TEST phase 2: cloud journal with firstsnapshot data
rm journal.db
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "journal.db*"
rm journal_test.db
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "journal_test.db*"
config=tests/config.toml
azcli=TestData/azcli3.sh
azcli2=TestData/azcli4.sh
Expand All @@ -125,7 +125,7 @@ azcli2=TestData/azcli4.sh
echo TEST update journal
echo python chorus_upload -v -c ${config} journal update --modalities OMOP,Waveforms
python chorus_upload -v -c ${config} journal update --modalities OMOP,Waveforms
cp journal.db TestData/journal2.1.db
cp journal_test.db TestData/journal2.1.db

echo TEST generate file list
echo python chorus_upload -v -c ${config} file list --modalities OMOP,Waveforms --output-file ${azcli} --output-type azcli --max-num-files 15
Expand All @@ -136,11 +136,11 @@ echo TEST with cloud journal and upload to central azcli
chmod a+x ${azcli}
# run the azcli script
eval ${azcli}
cp journal.db TestData/journal2.2.db
cp journal_test.db TestData/journal2.2.db

echo python chorus_upload -v -c ${config} journal update --modalities Images
python chorus_upload -v -c ${config} journal update --modalities Images
cp journal.db TestData/journal2.3.db
cp journal_test.db TestData/journal2.3.db


echo TEST generate file list again
Expand All @@ -152,24 +152,24 @@ echo TEST with cloud journal and upload to central azcli - AMENDING
chmod a+x ${azcli2}
# run the azcli script
eval ${azcli2}
cp journal.db TestData/journal2.4.db
cp journal_test.db TestData/journal2.4.db

echo TEST with cloud journal and upload to central built in - AMENDING
echo python chorus_upload -v -c ${config} file upload --modalities OMOP,Waveforms --max-num-files 15
python chorus_upload -v -c ${config} file upload --modalities OMOP,Waveforms --max-num-files 15
cp journal.db TestData/journal2.5.db
cp journal_test.db TestData/journal2.5.db


echo TEST update journal with second snapshot data
echo python chorus_upload -v -c ${config} journal update --modalities Images
python chorus_upload -v -c ${config} journal update --modalities Images
cp journal.db TestData/journal2.6.db
cp journal_test.db TestData/journal2.6.db


echo TEST with cloud journal and upload to central using builcloud
echo python chorus_upload -v -c ${config} file upload --modalities Images
python chorus_upload -v -c ${config} file upload --modalities Images
cp journal.db TestData/journal2.7.db
cp journal_test.db TestData/journal2.7.db

echo TEST verify the version
echo python chorus_upload -v -c ${config} file verify --modalities OMOP
Expand All @@ -178,30 +178,30 @@ python chorus_upload -v -c ${config} file verify --modalities OMOP

# ========================
echo TEST phase 3: mixture of local and cloud
rm journal.db
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "journal.db*"
rm journal_test.db
az storage blob delete-batch --account-name ${account} --source ${container} --sas-token ${sas} --pattern "journal_test.db*"
config=tests/config.toml
configlocal=tests/configlocal.toml # this should reference localjournal
azcli=TestData/azcli5.sh
azcli2=TestData/azcli6.sh
localjournal=journal.db
localjournal=journal_test.db

echo TEST checkout cloud journal, update, then check in.
echo python chorus_upload -v -c ${config} journal checkout --local-journal ${localjournal}
python chorus_upload -v -c ${config} journal checkout --local-journal ${localjournal}
cp journal.db TestData/journal3.1.db
cp journal_test.db TestData/journal3.1.db

echo python chorus_upload -v -c ${configlocal} journal update --modalities OMOP,Waveforms
python chorus_upload -v -c ${configlocal} journal update --modalities OMOP,Waveforms
cp journal.db TestData/journal3.2.db
cp journal_test.db TestData/journal3.2.db

echo python chorus_upload -v -c ${config} journal checkin --local-journal ${localjournal}
python chorus_upload -v -c ${config} journal checkin --local-journal ${localjournal}

echo TEST checkout cloud journal
echo python chorus_upload -v -c ${config} journal checkout --local-journal ${localjournal}
python chorus_upload -v -c ${config} journal checkout --local-journal ${localjournal}
cp journal.db TestData/journal3.3.db
cp journal_test.db TestData/journal3.3.db


echo TEST generate file list
Expand All @@ -213,7 +213,7 @@ echo TEST with local journal and upload to central azcli
chmod a+x ${azcli}
# run the azcli script
eval ${azcli}
cp journal.db TestData/journal3.4.db
cp journal_test.db TestData/journal3.4.db


echo TEST generate file list
Expand All @@ -225,7 +225,7 @@ echo TEST with local journal and upload to central azcli - AMENDING
chmod a+x ${azcli2}
# run the azcli script
eval ${azcli2}
cp journal.db TestData/journal3.5.db
cp journal_test.db TestData/journal3.5.db


echo TEST checkin journal
Expand All @@ -242,13 +242,13 @@ echo TEST with central journal and upload to central azcli - AMENDING
chmod a+x ${azcli}
# run the azcli script
eval ${azcli}
cp journal.db TestData/journal3.6.db
cp journal_test.db TestData/journal3.6.db


echo TEST with cloud journal upload to central built in - AMENDING
echo python chorus_upload -v -c ${config} file upload --modalities OMOP,Waveforms
python chorus_upload -v -c ${config} file upload --modalities OMOP,Waveforms
cp journal.db TestData/journal3.7.db
cp journal_test.db TestData/journal3.7.db

echo TEST verify the version
echo python chorus_upload -v -c ${config} file verify --modalities OMOP
Expand Down

0 comments on commit 197d359

Please sign in to comment.