Option --cloudfree added to upload-file method to manually set a measurement as cloud free during the upload

Wed, 28 Sep 2022 11:10:08 +0200

author
Claudio Dema <claudio.dema@imaa.cnr.it>
date
Wed, 28 Sep 2022 11:10:08 +0200
changeset 69
cd8bc07f8419
parent 68
70c869fa3242
child 70
4ef6f2102a61

Option --cloudfree added to upload-file method to manually set a measurement as cloud free during the upload

scc_access/scc_access.py file | annotate | diff | comparison | revisions
--- a/scc_access/scc_access.py	Wed May 25 23:00:57 2022 +0200
+++ b/scc_access/scc_access.py	Wed Sep 28 11:10:08 2022 +0200
@@ -123,8 +123,8 @@
         """ Logout from the SCC """
         return self.session.get(self.logout_url, stream=True)
 
-    def upload_file(self, filename, system_id, force_upload, delete_related, delay=0, rs_filename=None,
-                    ov_filename=None, lr_filename=None):
+    def upload_file(self, filename, system_id, force_upload, delete_related, delay=0, cloudfree=False,
+                    rs_filename=None, ov_filename=None, lr_filename=None):
         """ Upload a file for processing.
 
         If the upload is successful, it returns the measurement id.
@@ -142,6 +142,8 @@
            already present on the SCC server.
         delete_related : bool
            Answer to delete related question when deleting existing measurements from the SCC.
+        cloudfree : bool
+            Manually set the measurement as cloud free
         rs_filename, ov_filename, lr_filename : str
            Ancillary files pahts to be uploaded.
         """
@@ -172,9 +174,10 @@
 
         # Submit the data
         upload_data = {'system': system_id,
-                       'delay': delay}
+                       'delay': delay,
+                       'manually_cloud_free': cloudfree, }
 
-        logger.debug("Submitted processing parameters - System: {}, Delay: {}".format(system_id, delay))
+        logger.debug("Submitted processing parameters - System: {}, Delay: {}, Manually Cloud Free: {}".format(system_id, delay, cloudfree))
 
         files = {'data': open(filename, 'rb')}
 
@@ -406,8 +409,8 @@
             if monitor:
                 self.monitor_processing(measurement_id)
 
-    def process(self, filename, system_id, monitor, force_upload, delete_related, delay=0, rs_filename=None,
-                lr_filename=None, ov_filename=None):
+    def process(self, filename, system_id, monitor, force_upload, delete_related, delay=0, cloudfree=False,
+                rs_filename=None, lr_filename=None, ov_filename=None):
         """ Upload a file for processing and wait for the processing to finish.
         If the processing is successful, it will download all produced files.
         """
@@ -416,6 +419,7 @@
         logger.info("Uploading file.")
         measurement_id = self.upload_file(filename, system_id, force_upload, delete_related,
                                           delay=delay,
+                                          cloudfree=cloudfree,
                                           rs_filename=rs_filename,
                                           lr_filename=lr_filename,
                                           ov_filename=ov_filename)
@@ -905,7 +909,7 @@
 
 # Methods that use the SCC class to perform specific tasks.
 def process_file(filename, system_id, settings, force_upload, delete_related,
-                 delay=0, monitor=True, rs_filename=None, lr_filename=None, ov_filename=None):
+                 delay=0, cloudfree=False, monitor=True, rs_filename=None, lr_filename=None, ov_filename=None):
     """ Shortcut function to process a file to the SCC. """
     logger.info("Processing file %s, using system %s" % (filename, system_id))
 
@@ -915,6 +919,7 @@
                                   force_upload=force_upload,
                                   delete_related=delete_related,
                                   delay=delay,
+                                  cloudfree=cloudfree,
                                   monitor=monitor,
                                   rs_filename=rs_filename,
                                   lr_filename=lr_filename,
@@ -1065,6 +1070,7 @@
     def upload_file_from_args(parsed):
         process_file(parsed.filename, parsed.system, parsed.config,
                      delay=parsed.delay,
+                     cloudfree=parsed.cloudfree,
                      monitor=parsed.process,
                      force_upload=parsed.force_upload,
                      delete_related=False,  # For now, use this as default
@@ -1087,6 +1093,8 @@
     parser.add_argument("system", help="Processing system id.")
     parser.add_argument("--delay", help="Delay processing by the specified number of hours (0 to 96).",
                         default=0, type=delay)
+    parser.add_argument("--cloudfree", help="Manually assume this measurement as cloud free.",
+                        action="store_true", default=False)
     parser.add_argument("-p", "--process", help="Wait for the processing results.",
                         action="store_true")
     parser.add_argument("--force_upload", help="If measurement ID exists on SCC, delete before uploading.",

mercurial