Skip to content

Commit

Permalink
add a function to retrieve readme link
Browse files Browse the repository at this point in the history
  • Loading branch information
rugeli committed May 6, 2024
1 parent 805db23 commit e04a42f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
13 changes: 1 addition & 12 deletions cellpack/autopack/AWSHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -------------"
6 changes: 6 additions & 0 deletions cellpack/autopack/DBRecipeHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 0 additions & 3 deletions cellpack/autopack/FirebaseHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 11 additions & 1 deletion cellpack/autopack/upy/simularium/simularium_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cellpack/bin/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()} "
)


Expand Down

0 comments on commit e04a42f

Please sign in to comment.