From a543f751b311a53e3bbdd92be0a7b0eb03116665 Mon Sep 17 00:00:00 2001 From: e20643 Date: Tue, 19 Sep 2023 10:34:33 +0200 Subject: [PATCH 1/4] feat: add script to manual archive data --- bec_plugins/utils/csaxs_post_archive.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bec_plugins/utils/csaxs_post_archive.py b/bec_plugins/utils/csaxs_post_archive.py index 4d8e957..00a9b4b 100755 --- a/bec_plugins/utils/csaxs_post_archive.py +++ b/bec_plugins/utils/csaxs_post_archive.py @@ -125,8 +125,9 @@ class csaxs_archiver: command = f'datasetIngestor -allowexistingsource -ingest -autoarchive -noninteractive -token {self.token} {self.metadata_file} {self.datafile_name}' rtr = os.popen(command) - with open(os.path.join(fname,'_log.txt'), "w") as file: - file.write(rtr.read()) + #with open(os.path.join(fname,'_log.txt'), "w") as file: + # print(f'Writing reponse to file') + # file.write(rtr.read()) # result = subprocess.run(command, shell=False, stdout = subprocess.PIPE, stderr = subprocess.PIPE, universal_newlines=True) # if result.returncode == 0: # print(f"Command {command} was succesful") @@ -138,10 +139,10 @@ if __name__ == "__main__": # Generate dictionary with user input. user_input = { "base_path": "~/Data10", - "eacc": "e20639", + "eacc": "e20643", "pi": "Marianne Liebi", "pi_email": "marianne.liebi@psi.ch", 'log_path' : '~/Data10/documentation/ingestion_logs/' } - archiver = csaxs_archiver(start_scan=10, stop_scan=20, token='', **user_input) + archiver = csaxs_archiver(start_scan=1, stop_scan=349, token='csEwVQif0tuKZ11YtAMvGY0faEjv9JqxrBa9x3Z5E13oWXAMyaLxKtQrmzbemqj5', **user_input) archiver.run_for_all_scans() From d1cc075f89b037d2eeb9687919be1400ef4120fc Mon Sep 17 00:00:00 2001 From: appel_c Date: Tue, 19 Sep 2023 10:36:10 +0200 Subject: [PATCH 2/4] refactor: remove token from __main__ --- bec_plugins/utils/csaxs_post_archive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bec_plugins/utils/csaxs_post_archive.py b/bec_plugins/utils/csaxs_post_archive.py index 00a9b4b..bb740d2 100755 --- a/bec_plugins/utils/csaxs_post_archive.py +++ b/bec_plugins/utils/csaxs_post_archive.py @@ -144,5 +144,5 @@ if __name__ == "__main__": "pi_email": "marianne.liebi@psi.ch", 'log_path' : '~/Data10/documentation/ingestion_logs/' } - archiver = csaxs_archiver(start_scan=1, stop_scan=349, token='csEwVQif0tuKZ11YtAMvGY0faEjv9JqxrBa9x3Z5E13oWXAMyaLxKtQrmzbemqj5', **user_input) + archiver = csaxs_archiver(start_scan=1, stop_scan=349, token='', **user_input) archiver.run_for_all_scans() From 35ea790c19b6a09f7d0850cebe143f415c4ac5ff Mon Sep 17 00:00:00 2001 From: appel_c Date: Tue, 19 Sep 2023 10:38:48 +0200 Subject: [PATCH 3/4] fix: add documentation --- bec_plugins/utils/csaxs_post_archive.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bec_plugins/utils/csaxs_post_archive.py b/bec_plugins/utils/csaxs_post_archive.py index bb740d2..8f58f90 100755 --- a/bec_plugins/utils/csaxs_post_archive.py +++ b/bec_plugins/utils/csaxs_post_archive.py @@ -9,7 +9,8 @@ from bec_lib.core.file_utils import FileWriterMixin class csaxs_archiver: """Class to archive data from a beamtime. To run this script from a shell, go to discovery.psi.ch and copy your token. - Afterwards, get a Keberos token (kinit) for yourself in the shell that you run this code. + Afterwards, get a Keberos token (kinit) for yourself in the shell. + Activate the bec_venv by doing "source bec_venv/bin/activate" and then run this code via python $filename. As a last step, adjust the dictionary below in if __name__ == '__main__' with your token as well as information about the experiment """ From 17d90fced00e76788a3bb18277fb69c1c3da12b5 Mon Sep 17 00:00:00 2001 From: appel_c Date: Tue, 19 Sep 2023 10:45:04 +0200 Subject: [PATCH 4/4] fix: small adjustments of ddocs and function call --- bec_plugins/utils/csaxs_post_archive.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bec_plugins/utils/csaxs_post_archive.py b/bec_plugins/utils/csaxs_post_archive.py index 8f58f90..a874e56 100755 --- a/bec_plugins/utils/csaxs_post_archive.py +++ b/bec_plugins/utils/csaxs_post_archive.py @@ -9,6 +9,7 @@ from bec_lib.core.file_utils import FileWriterMixin class csaxs_archiver: """Class to archive data from a beamtime. To run this script from a shell, go to discovery.psi.ch and copy your token. + Complement the information in user_input below in the if __name__ == __main__ part of the script. Afterwards, get a Keberos token (kinit) for yourself in the shell. Activate the bec_venv by doing "source bec_venv/bin/activate" and then run this code via python $filename. As a last step, adjust the dictionary below in if __name__ == '__main__' with your token as well as information about the experiment @@ -143,7 +144,10 @@ if __name__ == "__main__": "eacc": "e20643", "pi": "Marianne Liebi", "pi_email": "marianne.liebi@psi.ch", - 'log_path' : '~/Data10/documentation/ingestion_logs/' + 'log_path' : '~/Data10/documentation/ingestion_logs/', + 'token' : '', + 'start_scan' : 0, + 'stop_scan' : 0, } - archiver = csaxs_archiver(start_scan=1, stop_scan=349, token='', **user_input) + archiver = csaxs_archiver(**user_input) archiver.run_for_all_scans()