diff --git a/cellpack/autopack/AWSHandler.py b/cellpack/autopack/AWSHandler.py index 21cb63e1..977b0608 100644 --- a/cellpack/autopack/AWSHandler.py +++ b/cellpack/autopack/AWSHandler.py @@ -122,17 +122,6 @@ def save_file_and_get_url(self, file_path): if self.is_url_valid(base_url): return file_name, base_url except NoCredentialsError as e: - print(self.skip_aws_credentials(e)) + print(f"AWS credentials are not configured, details:{e}") return None, None return None, None - - @staticmethod - def skip_aws_credentials(e): - """ - Handles the case when AWS credentials are not configured. - Provides a detailed error message and instruction. - """ - aws_readme_url = ( - "https://github.com/mesoscope/cellpack/blob/main/README.md#aws-s3" - ) - return f"AWS credentials are not configured, details:{e}. If needed, refer to the instructions at {aws_readme_url}. \nSkipping the opening of new browser tabs -------------" diff --git a/cellpack/autopack/DBRecipeHandler.py b/cellpack/autopack/DBRecipeHandler.py index d166621d..c5b9bf22 100644 --- a/cellpack/autopack/DBRecipeHandler.py +++ b/cellpack/autopack/DBRecipeHandler.py @@ -771,3 +771,9 @@ def cleanup_results(self): Check if the results in the database are expired and delete them if the linked object expired. """ self.result_doc.handle_expired_results() + + def readme_url(self): + """ + Return the URL to the README file for the database setup section. + """ + return "https://github.com/mesoscope/cellpack?tab=readme-ov-file#introduction-to-remote-databases" diff --git a/cellpack/autopack/FirebaseHandler.py b/cellpack/autopack/FirebaseHandler.py index ad0750dd..a4c60f22 100644 --- a/cellpack/autopack/FirebaseHandler.py +++ b/cellpack/autopack/FirebaseHandler.py @@ -123,9 +123,6 @@ def get_staging_creds(): FIREBASE_TOKEN = os.getenv("FIREBASE_TOKEN") FIREBASE_EMAIL = os.getenv("FIREBASE_EMAIL") if not FIREBASE_TOKEN or not FIREBASE_EMAIL: - print( - "Firebase credentials are not found. If needed, please contact the code owner for assistance. \nSkipping firebase staging database -------------" - ) return firebase_key = FIREBASE_TOKEN.replace("\\n", "\n") return { diff --git a/cellpack/autopack/upy/simularium/simularium_helper.py b/cellpack/autopack/upy/simularium/simularium_helper.py index 423a7872..457e0c85 100644 --- a/cellpack/autopack/upy/simularium/simularium_helper.py +++ b/cellpack/autopack/upy/simularium/simularium_helper.py @@ -22,7 +22,7 @@ from simulariumio.constants import DISPLAY_TYPE, VIZ_TYPE from cellpack.autopack.upy import hostHelper -from cellpack.autopack.DBRecipeHandler import DBUploader +from cellpack.autopack.DBRecipeHandler import DBUploader, DBMaintenance from cellpack.autopack.interface_objects.database_ids import DATABASE_IDS import collada @@ -1407,6 +1407,11 @@ def store_result_file(file_path, storage=None): region_name="us-west-2", ) file_name, url = initialized_handler.save_file_and_get_url(file_path) + if not file_name or not url: + db_maintainer = DBMaintenance(initialized_handler) + print( + f"If AWS access needed, please refer to the instructions at {db_maintainer.readme_url()}. \nSkipping the opening of new browser tabs -------------" + ) return file_name, url @staticmethod @@ -1419,6 +1424,11 @@ def store_metadata(file_name, url, db=None): if initialized_db._initialized: db_uploader = DBUploader(initialized_db) db_uploader.upload_result_metadata(file_name, url) + else: + db_maintainer = DBMaintenance(initialized_db) + print( + f"Firebase credentials are not found. If needed, please refer to the instructions at {db_maintainer.readme_url()}. \nSkipping firebase staging database -------------" + ) return @staticmethod diff --git a/cellpack/bin/upload.py b/cellpack/bin/upload.py index 4d206cc2..62f1b9f1 100644 --- a/cellpack/bin/upload.py +++ b/cellpack/bin/upload.py @@ -2,7 +2,7 @@ import fire from cellpack.autopack.FirebaseHandler import FirebaseHandler -from cellpack.autopack.DBRecipeHandler import DBUploader +from cellpack.autopack.DBRecipeHandler import DBUploader, DBMaintenance from cellpack.autopack.interface_objects.database_ids import DATABASE_IDS from cellpack.autopack.loaders.recipe_loader import RecipeLoader @@ -27,8 +27,9 @@ def upload( recipe_db_handler = DBUploader(db_handler) recipe_db_handler.upload_recipe(recipe_meta_data, recipe_full_data) else: + db_maintainer = DBMaintenance(db_handler) sys.exit( - "The selected database is not initialized. Please set up Firebase credentials to upload recipes." + f"The selected database is not initialized. Please set up Firebase credentials to upload recipes. Refer to the instructions at {db_maintainer.readme_url()} " )