Skip to content

Commit

Permalink
Update Error Messages for iRODS Related Errors (#27)
Browse files Browse the repository at this point in the history
* Update connection error and make error for incorrect model message earlier
  • Loading branch information
tjstruck authored Jan 23, 2025
1 parent 531c7a6 commit 7b2e2af
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion donni/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from scipy.stats import norm

# irods packages
import irods
from irods.session import iRODSSession
from irods.models import Collection, DataObject
import irods.exception as exception
Expand Down Expand Up @@ -80,6 +81,23 @@ def irods_download(dem_model, sample_sizes, fold, datadir, model_version):
# Start irods with the Cyvers Data Store
session = iRODSSession(host='data.cyverse.org', port=1247, user='anonymous', zone='iplant')

try:
max([version.name for version in session.collections.get(f"/iplant/home/shared/donni/{dem_model}/{polarization}/ss_{'_'.join([str(ele) for ele in sample_sizes])}").subcollections])
except exception.CollectionDoesNotExist:
exception.CollectionDoesNotExist("The requested demographic model does not exist on the CyVerse Data Store or the site-frequency spectrum populations are missmatched with the model." \
"Users can check for available models at https://de.cyverse.org/data/ds/iplant/home/shared/donni" \
"If the user has generated their own trained MLPRs, use --mlpr_dir")
except exception.NetworkException:
raise exception.NetworkException(
"\n\n\n======================================\n============ donni error summary =====\n======================================\n" \
"Error accessing donni MLPR(s) through irods/the Cyverse DataStore. This may be due to the DataStore being down or a firewall interupting the connection.\n" \
"If this issue persists, you can manually download the MLPRs and use --mlpr_dir to point donni infer to a directory that has the MLPRs.\n\n" \
"The URL for your requested MLPRs:\n" \
f"https://de.cyverse.org/data/ds/iplant/home/shared/donni/{dem_model}/{polarization}/ss_{'_'.join([str(ele) for ele in sample_sizes])}/\n" \
"Then navigate through the version you want or the latest and then tuned_models.\n" \
"ex.\n" \
f"https://de.cyverse.org/data/ds/iplant/home/shared/donni/{dem_model}/{polarization}/ss_{'_'.join([str(ele) for ele in sample_sizes])}/v0.9.0/tuned_models/ mlprs/\n")

if model_version == None:
model_version = max([version.name for version in session.collections.get(f"/iplant/home/shared/donni/{dem_model}/{polarization}/ss_{'_'.join([str(ele) for ele in sample_sizes])}").subcollections])
else:
Expand All @@ -91,7 +109,7 @@ def irods_download(dem_model, sample_sizes, fold, datadir, model_version):
tuned_models = session.collections.get(f"/iplant/home/shared/donni/{dem_model}/{polarization}/ss_{'_'.join([str(ele) for ele in sample_sizes])}/{model_version}/tuned_models")
plots = session.collections.get(f"/iplant/home/shared/donni/{dem_model}/{polarization}/ss_{'_'.join([str(ele) for ele in sample_sizes])}/{model_version}/plots")
except exception.CollectionDoesNotExist:
print("The requested demographic model does not exist on the CyVerse Data Store.")
print("The requested demographic model does not exist on the CyVerse Data Store or the site-frequency spectrum populations are missmatched with the model.")
print("Users can check for available models at https://de.cyverse.org/data/ds/iplant/home/shared/donni")
print("If the user has generated their own trained MLPRs, use --mlpr_dir")
# Exit, might break downstream functions
Expand Down

0 comments on commit 7b2e2af

Please sign in to comment.