From 9688c0337be09f68cda02281ce93ea1c588bc7e2 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Fri, 5 Feb 2021 09:39:35 +0100 Subject: [PATCH 01/10] tell the user if there are indexing problems --- validphys2/src/validphys/uploadutils.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index 7f2d6a79bb..d2e21980da 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -181,14 +181,15 @@ class FitUploader(FileUploader): def get_relative_path(self, output_path=None): return '' - def check_fit_exists(self, fit_name): + def check_fit_exists(self, fit_name, silent=False): """Check whether the fit already exists on the server.""" # Get list of the available fits on the server l = RemoteLoader() fits = l.downloadable_fits if fit_name in fits: - log.error("A fit with the same name already exists on " + if not silent: + log.error("A fit with the same name already exists on " "the server. To overwrite this fit use the " "--force flag, as in `vp-upload " "--force`.") @@ -255,6 +256,16 @@ def upload_output(self, output_path, force): new_out, name = self.compress(output_path) super().upload_output(new_out) + # Check whether the fit was really uploaded + try: + log.info("Checking whether the fit was correctly uploaded...") + from time import sleep + sleep(20) + self.check_fit_exists(fit_name, silent=True) + log.error("The fit was uploaded but haven't been indexed yet by the server") + except UploadError: + log.info("The fit has been indexed by the server") + shutil.rmtree(new_out) return name.with_suffix('.tar.gz').name From 546293118fbac981ea2f1c647753066c7b6769e5 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Mon, 22 Feb 2021 15:31:57 +0100 Subject: [PATCH 02/10] clean up --- validphys2/src/validphys/uploadutils.py | 38 ++++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index d2e21980da..9a476e922c 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -3,6 +3,7 @@ Tools to upload resources to remote servers. """ +import time import subprocess import logging import os @@ -181,19 +182,16 @@ class FitUploader(FileUploader): def get_relative_path(self, output_path=None): return '' - def check_fit_exists(self, fit_name, silent=False): - """Check whether the fit already exists on the server.""" + def check_fit_exists(self, fit_name): + """Check whether the fit already exists on the server. + Returns true if a fit exists with the same name on the server or false otherwise + """ # Get list of the available fits on the server l = RemoteLoader() fits = l.downloadable_fits if fit_name in fits: - if not silent: - log.error("A fit with the same name already exists on " - "the server. To overwrite this fit use the " - "--force flag, as in `vp-upload " - "--force`.") - raise UploadError + return True def check_fit_md5(self, output_path): """When ``vp-setupfit`` is successfully ran, it creates an ``md5`` from @@ -249,7 +247,13 @@ def upload_output(self, output_path, force): fit_name = output_path.name if not force: - self.check_fit_exists(fit_name) + if self.check_fit_exists(fit_name): + log.error("A fit with the same name already exists on " + "the server. To overwrite this fit use the " + "--force flag, as in `vp-upload " + "--force`.") + raise UploadError + self.check_fit_md5(output_path) @@ -257,14 +261,14 @@ def upload_output(self, output_path, force): super().upload_output(new_out) # Check whether the fit was really uploaded - try: - log.info("Checking whether the fit was correctly uploaded...") - from time import sleep - sleep(20) - self.check_fit_exists(fit_name, silent=True) - log.error("The fit was uploaded but haven't been indexed yet by the server") - except UploadError: - log.info("The fit has been indexed by the server") + log.info("Checking whether the fit was correctly uploaded...") + time.sleep(3) + if self.check_fit_exists(fit_name): + log.info("The fit has been correctly indexed by the server!") + else: + log.error("The fit was uploaded but haven't been indexed yet by the server " + "you might want to try to upload it again to ensure it is indexed: " + "vp-upload %s", fit_name) shutil.rmtree(new_out) return name.with_suffix('.tar.gz').name From 0276396405f9b38b86cccd923b9532dbd224440f Mon Sep 17 00:00:00 2001 From: juacrumar Date: Mon, 22 Feb 2021 15:46:01 +0100 Subject: [PATCH 03/10] add the check also for PDF input --- validphys2/src/validphys/uploadutils.py | 46 +++++++++++++++++-------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index 9a476e922c..743a4317dc 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -192,6 +192,23 @@ def check_fit_exists(self, fit_name): if fit_name in fits: return True + return False + + def _check_existence(self, fit_name): + """ Wrapper for the correct existence method """ + return self.check_fit_exists(fit_name) + + def check_is_indexed(self, fit_name): + """ Check whether the fit is correctly indexed in the server + """ + log.info("Checking whether %s was correctly uploaded...", fit_name) + time.sleep(3) + if self._check_existence(fit_name): + log.info("It has been correctly indexed by the server!") + else: + log.error("The object was uploaded but haven't been indexed yet by the server " + "you might want to try to upload it again to ensure it is indexed: " + "vp-upload %s", fit_name) def check_fit_md5(self, output_path): """When ``vp-setupfit`` is successfully ran, it creates an ``md5`` from @@ -261,14 +278,7 @@ def upload_output(self, output_path, force): super().upload_output(new_out) # Check whether the fit was really uploaded - log.info("Checking whether the fit was correctly uploaded...") - time.sleep(3) - if self.check_fit_exists(fit_name): - log.info("The fit has been correctly indexed by the server!") - else: - log.error("The fit was uploaded but haven't been indexed yet by the server " - "you might want to try to upload it again to ensure it is indexed: " - "vp-upload %s", fit_name) + self.check_is_indexed(fit_name) shutil.rmtree(new_out) return name.with_suffix('.tar.gz').name @@ -302,11 +312,12 @@ def check_pdf_exists(self, pdf_name): pdfs = l.downloadable_pdfs if pdf_name in pdfs: - log.error("A PDF with the same name already exists on " - "the server. To overwrite this PDF use the " - "--force flag, as in `vp-upload " - "--force`.") - raise UploadError + return True + return False + + def _check_existence(self, fit_name): + """ Wrapper for the correct existence method """ + return self.check_pdf_exists(fit_name) def compress(self, output_path): """Compress the folder and put it in a directory inside its parent.""" @@ -332,11 +343,18 @@ def upload_output(self, output_path, force): pdf_name = output_path.name if not force: - self.check_pdf_exists(pdf_name) + if self.check_pdf_exists(pdf_name): + log.error("A PDF with the same name already exists on " + "the server. To overwrite this PDF use the " + "--force flag, as in `vp-upload " + "--force`.") + raise UploadError new_out, name = self.compress(output_path) super(FileUploader, self).upload_output(new_out) + self.check_is_indexed(pdf_name) + shutil.rmtree(new_out) return name.with_suffix('.tar.gz').name From 2983a39c515a73195c9940b6b26024ee79ddbb5f Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 23 Feb 2021 10:25:00 +0100 Subject: [PATCH 04/10] merge existence --- validphys2/src/validphys/uploadutils.py | 39 ++++++++----------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index 743a4317dc..9daff939c0 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -178,26 +178,24 @@ class FitUploader(FileUploader): before uploading.""" target_dir = _profile_key('fits_target_dir') root_url = _profile_key('fits_root_url') + _loader_name = "downloadable_fits" def get_relative_path(self, output_path=None): return '' - def check_fit_exists(self, fit_name): - """Check whether the fit already exists on the server. - Returns true if a fit exists with the same name on the server or false otherwise + def _check_existence(self, resource_name): + """ Check whether the given resource exists on the server + Returns true if the resource exists with the same name on the server + or false otherwise. + Note that the type of resource being checked is defined by the ``_loader_name`` attribute """ - # Get list of the available fits on the server l = RemoteLoader() - fits = l.downloadable_fits + resource_list = getattr(l, self._loader_name) - if fit_name in fits: + if resource_name in resource_list: return True return False - def _check_existence(self, fit_name): - """ Wrapper for the correct existence method """ - return self.check_fit_exists(fit_name) - def check_is_indexed(self, fit_name): """ Check whether the fit is correctly indexed in the server """ @@ -264,7 +262,7 @@ def upload_output(self, output_path, force): fit_name = output_path.name if not force: - if self.check_fit_exists(fit_name): + if self._check_existence(fit_name): log.error("A fit with the same name already exists on " "the server. To overwrite this fit use the " "--force flag, as in `vp-upload " @@ -299,25 +297,13 @@ def upload_or_exit_context(self, output, force): log.error(e) sys.exit() + class PDFUploader(FitUploader): """An uploader for PDFs. PDFs will be automatically compressed before uploading.""" target_dir = _profile_key('pdfs_target_dir') root_url = _profile_key('pdfs_root_url') - - def check_pdf_exists(self, pdf_name): - """Check whether the pdf already exists on the server.""" - # Get list of the available fits on the server - l = RemoteLoader() - pdfs = l.downloadable_pdfs - - if pdf_name in pdfs: - return True - return False - - def _check_existence(self, fit_name): - """ Wrapper for the correct existence method """ - return self.check_pdf_exists(fit_name) + _loader_name = "downloadable_pdfs" def compress(self, output_path): """Compress the folder and put it in a directory inside its parent.""" @@ -337,13 +323,12 @@ def compress(self, output_path): raise UploadError(e) from e return tempdir, archive_path_without_extension - def upload_output(self, output_path, force): output_path = pathlib.Path(output_path) pdf_name = output_path.name if not force: - if self.check_pdf_exists(pdf_name): + if self._check_existence(pdf_name): log.error("A PDF with the same name already exists on " "the server. To overwrite this PDF use the " "--force flag, as in `vp-upload " From cb19c0bc18a6bf420be489058f97782366ceeedb Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 23 Feb 2021 10:31:20 +0100 Subject: [PATCH 05/10] complete merge --- validphys2/src/validphys/uploadutils.py | 60 +++++-------------------- 1 file changed, 12 insertions(+), 48 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index 9daff939c0..fa226eb305 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -179,6 +179,7 @@ class FitUploader(FileUploader): target_dir = _profile_key('fits_target_dir') root_url = _profile_key('fits_root_url') _loader_name = "downloadable_fits" + _resource_type = "fit" def get_relative_path(self, output_path=None): return '' @@ -204,7 +205,7 @@ def check_is_indexed(self, fit_name): if self._check_existence(fit_name): log.info("It has been correctly indexed by the server!") else: - log.error("The object was uploaded but haven't been indexed yet by the server " + log.error("The object is uploaded but haven't been indexed yet by the server " "you might want to try to upload it again to ensure it is indexed: " "vp-upload %s", fit_name) @@ -238,13 +239,13 @@ def check_fit_md5(self, output_path): ) raise UploadError - def compress(self, output_path): + def _compress(self, output_path): """Compress the folder and put in in a directory inside its parent.""" #make_archive fails if we give it relative paths for some reason output_path = output_path.resolve() - tempdir = tempfile.mkdtemp(prefix='fit_upload_deleteme_', + tempdir = tempfile.mkdtemp(prefix=f'{self._resource_type}_upload_deleteme_', dir=output_path.parent) - log.info(f"Compressing fit to {tempdir}") + log.info(f"Compressing {self._resource_type} to {tempdir}") archive_path_without_extension = pathlib.Path(tempdir)/(output_path.name) try: with Spinner(): @@ -263,16 +264,16 @@ def upload_output(self, output_path, force): if not force: if self._check_existence(fit_name): - log.error("A fit with the same name already exists on " + log.error("A %s with the same name already exists on " "the server. To overwrite this fit use the " - "--force flag, as in `vp-upload " - "--force`.") + "--force flag, as in `vp-upload <%s_name> " + "--force`.", self._resource_type, self._resource_type) raise UploadError + if self._resource_type == "fit": + self.check_fit_md5(output_path) - self.check_fit_md5(output_path) - - new_out, name = self.compress(output_path) + new_out, name = self._compress(output_path) super().upload_output(new_out) # Check whether the fit was really uploaded @@ -304,44 +305,7 @@ class PDFUploader(FitUploader): target_dir = _profile_key('pdfs_target_dir') root_url = _profile_key('pdfs_root_url') _loader_name = "downloadable_pdfs" - - def compress(self, output_path): - """Compress the folder and put it in a directory inside its parent.""" - # make_archive fails if we give it relative paths for some reason - output_path = output_path.resolve() - tempdir = tempfile.mkdtemp(prefix='pdf_upload_deleteme_', - dir=output_path.parent) - log.info(f"Compressing pdf to {tempdir}") - archive_path_without_extension = pathlib.Path(tempdir)/(output_path.name) - try: - with Spinner(): - shutil.make_archive(base_name=archive_path_without_extension, - format='gztar', - root_dir=output_path.parent, base_dir=output_path.name) - except Exception as e: - log.error(f"Couldn't compress archive: {e}") - raise UploadError(e) from e - return tempdir, archive_path_without_extension - - def upload_output(self, output_path, force): - output_path = pathlib.Path(output_path) - pdf_name = output_path.name - - if not force: - if self._check_existence(pdf_name): - log.error("A PDF with the same name already exists on " - "the server. To overwrite this PDF use the " - "--force flag, as in `vp-upload " - "--force`.") - raise UploadError - - new_out, name = self.compress(output_path) - super(FileUploader, self).upload_output(new_out) - - self.check_is_indexed(pdf_name) - - shutil.rmtree(new_out) - return name.with_suffix('.tar.gz').name + _resource_type = "pdf" def check_for_meta(path): From cc857534747574d74acdc0d0dcc0320e72eb1c1e Mon Sep 17 00:00:00 2001 From: juacrumar Date: Tue, 23 Feb 2021 12:42:48 +0100 Subject: [PATCH 06/10] addresses some review comments --- validphys2/src/validphys/uploadutils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index fa226eb305..74ca91d927 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -205,9 +205,8 @@ def check_is_indexed(self, fit_name): if self._check_existence(fit_name): log.info("It has been correctly indexed by the server!") else: - log.error("The object is uploaded but haven't been indexed yet by the server " - "you might want to try to upload it again to ensure it is indexed: " - "vp-upload %s", fit_name) + log.error("The object is uploaded but hasn't been indexed yet by the server " + "you should upload it again to ensure it is indexed: vp-upload %s", fit_name) def check_fit_md5(self, output_path): """When ``vp-setupfit`` is successfully ran, it creates an ``md5`` from @@ -265,9 +264,9 @@ def upload_output(self, output_path, force): if not force: if self._check_existence(fit_name): log.error("A %s with the same name already exists on " - "the server. To overwrite this fit use the " - "--force flag, as in `vp-upload <%s_name> " - "--force`.", self._resource_type, self._resource_type) + "the server. To overwrite it use the " + "--force flag, as in `vp-upload <%s_name> --force.", + self._resource_type, self._resource_type) raise UploadError if self._resource_type == "fit": From 392026da4083b9e3b9ce7c60132721570dd48510 Mon Sep 17 00:00:00 2001 From: juacrumar Date: Thu, 25 Feb 2021 15:47:50 +0100 Subject: [PATCH 07/10] OOPization --- validphys2/src/validphys/uploadutils.py | 102 +++++++++++++----------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index 74ca91d927..88d1c5f791 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -173,13 +173,13 @@ def upload_context(self, output_and_file): class ReportFileUploader(FileUploader, ReportUploader): pass -class FitUploader(FileUploader): - """An uploader for fits. Fits will be automatically compressed - before uploading.""" - target_dir = _profile_key('fits_target_dir') - root_url = _profile_key('fits_root_url') - _loader_name = "downloadable_fits" - _resource_type = "fit" + +class ArchiveUploader(FileUploader): + """ Uploader for objects comprising many files such as fits or PDFs """ + target_dir = None + root_url = None + _loader_name = None # vp loader for this kind of archive + _resource_type = "Archive" # name used during logging def get_relative_path(self, output_path=None): return '' @@ -197,46 +197,16 @@ def _check_existence(self, resource_name): return True return False - def check_is_indexed(self, fit_name): + def check_is_indexed(self, resource_name): """ Check whether the fit is correctly indexed in the server """ - log.info("Checking whether %s was correctly uploaded...", fit_name) + log.info("Checking whether %s was correctly uploaded...", resource_name) time.sleep(3) - if self._check_existence(fit_name): + if self._check_existence(resource_name): log.info("It has been correctly indexed by the server!") else: log.error("The object is uploaded but hasn't been indexed yet by the server " - "you should upload it again to ensure it is indexed: vp-upload %s", fit_name) - - def check_fit_md5(self, output_path): - """When ``vp-setupfit`` is successfully ran, it creates an ``md5`` from - the config. We check that the ``md5`` matches the ``filter.yml`` which - is checking that ``vp-setupfit`` was ran and that the ``filter.yml`` - inside the fit folder wasn't modified. - - """ - md5_path = output_path / "md5" - try: - with open(md5_path, "r") as f: - saved_md5 = f.read() - except FileNotFoundError as e: - log.error( - "It doesn't appear that `vp-setupfit` was ran because no `md5` " - "was found, `vp-setupfit` should be ran before uploading a fit." - ) - raise UploadError(f"Fit MD5 file not found at {md5_path}") from e - - with open(output_path / "filter.yml", "rb") as f: - hashed_config = hashlib.md5(f.read()).hexdigest() - - if hashed_config != saved_md5: - log.error( - "Saved md5 doesn't match saved fit configuration runcard, which " - "suggests that the configuration file was modified after it was " - "saved. /filter.yml shouldn't be modified directly. " - "Instead modify the fit runcard and re-run ``vp-setupfit``." - ) - raise UploadError + "you should upload it again to ensure it is indexed: vp-upload %s", resource_name) def _compress(self, output_path): """Compress the folder and put in in a directory inside its parent.""" @@ -256,7 +226,6 @@ def _compress(self, output_path): raise UploadError(e) from e return tempdir, archive_path_without_extension - def upload_output(self, output_path, force): output_path = pathlib.Path(output_path) fit_name = output_path.name @@ -269,9 +238,6 @@ def upload_output(self, output_path, force): self._resource_type, self._resource_type) raise UploadError - if self._resource_type == "fit": - self.check_fit_md5(output_path) - new_out, name = self._compress(output_path) super().upload_output(new_out) @@ -298,7 +264,51 @@ def upload_or_exit_context(self, output, force): sys.exit() -class PDFUploader(FitUploader): +class FitUploader(ArchiveUploader): + """An uploader for fits. Fits will be automatically compressed + before uploading.""" + target_dir = _profile_key('fits_target_dir') + root_url = _profile_key('fits_root_url') + _loader_name = "downloadable_fits" + _resource_type = "fit" + + def check_fit_md5(self, output_path): + """When ``vp-setupfit`` is successfully ran, it creates an ``md5`` from + the config. We check that the ``md5`` matches the ``filter.yml`` which + is checking that ``vp-setupfit`` was ran and that the ``filter.yml`` + inside the fit folder wasn't modified. + + """ + md5_path = output_path / "md5" + try: + with open(md5_path, "r") as f: + saved_md5 = f.read() + except FileNotFoundError as e: + log.error( + "It doesn't appear that `vp-setupfit` was ran because no `md5` " + "was found, `vp-setupfit` should be ran before uploading a fit." + ) + raise UploadError(f"Fit MD5 file not found at {md5_path}") from e + + with open(output_path / "filter.yml", "rb") as f: + hashed_config = hashlib.md5(f.read()).hexdigest() + + if hashed_config != saved_md5: + log.error( + "Saved md5 doesn't match saved fit configuration runcard, which " + "suggests that the configuration file was modified after it was " + "saved. /filter.yml shouldn't be modified directly. " + "Instead modify the fit runcard and re-run ``vp-setupfit``." + ) + raise UploadError + + def upload_output(self, output_path, force): + output_path = pathlib.Path(output_path) + self.check_fit_md5(output_path) + return super().upload_output(output_path, force) + + +class PDFUploader(ArchiveUploader): """An uploader for PDFs. PDFs will be automatically compressed before uploading.""" target_dir = _profile_key('pdfs_target_dir') From 324fc089652f3c4bc65ae96bf12c5b8368666a44 Mon Sep 17 00:00:00 2001 From: Juacrumar Date: Wed, 3 Mar 2021 11:55:59 +0100 Subject: [PATCH 08/10] Apply suggestions from code review Co-authored-by: Cameron Voisey <32741139+voisey@users.noreply.github.com> --- validphys2/src/validphys/uploadutils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index 88d1c5f791..dce0f9fa93 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -185,7 +185,7 @@ def get_relative_path(self, output_path=None): return '' def _check_existence(self, resource_name): - """ Check whether the given resource exists on the server + """ Check whether the given resource exists on the server. Returns true if the resource exists with the same name on the server or false otherwise. Note that the type of resource being checked is defined by the ``_loader_name`` attribute @@ -205,8 +205,8 @@ def check_is_indexed(self, resource_name): if self._check_existence(resource_name): log.info("It has been correctly indexed by the server!") else: - log.error("The object is uploaded but hasn't been indexed yet by the server " - "you should upload it again to ensure it is indexed: vp-upload %s", resource_name) + log.error("The object is uploaded but hasn't been indexed yet by the server. " + "You should upload it again to ensure it is indexed: vp-upload %s", resource_name) def _compress(self, output_path): """Compress the folder and put in in a directory inside its parent.""" @@ -273,9 +273,9 @@ class FitUploader(ArchiveUploader): _resource_type = "fit" def check_fit_md5(self, output_path): - """When ``vp-setupfit`` is successfully ran, it creates an ``md5`` from + """When ``vp-setupfit`` is run successfully, it creates an ``md5`` from the config. We check that the ``md5`` matches the ``filter.yml`` which - is checking that ``vp-setupfit`` was ran and that the ``filter.yml`` + is checking that ``vp-setupfit`` was run and that the ``filter.yml`` inside the fit folder wasn't modified. """ @@ -285,8 +285,8 @@ def check_fit_md5(self, output_path): saved_md5 = f.read() except FileNotFoundError as e: log.error( - "It doesn't appear that `vp-setupfit` was ran because no `md5` " - "was found, `vp-setupfit` should be ran before uploading a fit." + "It doesn't appear that `vp-setupfit` was run because no `md5` " + "was found, `vp-setupfit` should be run before uploading a fit." ) raise UploadError(f"Fit MD5 file not found at {md5_path}") from e From abdfa3076fac7141f95e4d4a19417c50ea9965ad Mon Sep 17 00:00:00 2001 From: juacrumar Date: Wed, 3 Mar 2021 12:05:29 +0100 Subject: [PATCH 09/10] add underscore --- validphys2/src/validphys/uploadutils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index dce0f9fa93..f84796c2f2 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -197,7 +197,7 @@ def _check_existence(self, resource_name): return True return False - def check_is_indexed(self, resource_name): + def _check_is_indexed(self, resource_name): """ Check whether the fit is correctly indexed in the server """ log.info("Checking whether %s was correctly uploaded...", resource_name) @@ -242,7 +242,7 @@ def upload_output(self, output_path, force): super().upload_output(new_out) # Check whether the fit was really uploaded - self.check_is_indexed(fit_name) + self._check_is_indexed(fit_name) shutil.rmtree(new_out) return name.with_suffix('.tar.gz').name From fe7c73b078754bdb72420f014a9e7fbfaf10cded Mon Sep 17 00:00:00 2001 From: Zaharid Date: Fri, 5 Mar 2021 18:08:25 +0100 Subject: [PATCH 10/10] Simplify control logic --- validphys2/src/validphys/uploadutils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/validphys2/src/validphys/uploadutils.py b/validphys2/src/validphys/uploadutils.py index f84796c2f2..944e638ba8 100644 --- a/validphys2/src/validphys/uploadutils.py +++ b/validphys2/src/validphys/uploadutils.py @@ -193,9 +193,7 @@ def _check_existence(self, resource_name): l = RemoteLoader() resource_list = getattr(l, self._loader_name) - if resource_name in resource_list: - return True - return False + return resource_name in resource_list def _check_is_indexed(self, resource_name): """ Check whether the fit is correctly indexed in the server