You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when MS2PIPFeatureGenerator calls ms2pip.correlate(), the latter may download xgboost_models_files from the Internet if they are not present in the model_dir directory. Can we please have a control to disable this behaviour?
It's possible to do by monkey patching. At the top of your script, before importing anything from MS2Rescore or MS2PIP, add these lines:
import urllib.request
def _raise_urllib_exception(*args, **kwargs):
raise urllib.error.URLError("Downloading from the Internet is prevented in this build.")
urllib.request.urlretrieve = _raise_urllib_exception
from ms2rescore.feature_generators.ms2pip import MS2PIPFeatureGenerator
The code targeted is in ms2pip/_utils/xgb_models.py, def _download_model(), which uses urllib.request.urlretrieve. The trick relies on the fact that there is always only one instance of an imported module, so messing with urllib.request before ms2pip imports it guarantees that ms2pip sees the same monkey-patched instance.
Obviously, this is rather poor practice and some option passed to MS2PIPFeatureGenerator would be much nicer.
The text was updated successfully, but these errors were encountered:
Currently, when MS2PIPFeatureGenerator calls ms2pip.correlate(), the latter may download xgboost_models_files from the Internet if they are not present in the model_dir directory. Can we please have a control to disable this behaviour?
It's possible to do by monkey patching. At the top of your script, before importing anything from MS2Rescore or MS2PIP, add these lines:
The code targeted is in ms2pip/_utils/xgb_models.py, def _download_model(), which uses urllib.request.urlretrieve. The trick relies on the fact that there is always only one instance of an imported module, so messing with urllib.request before ms2pip imports it guarantees that ms2pip sees the same monkey-patched instance.
Obviously, this is rather poor practice and some option passed to MS2PIPFeatureGenerator would be much nicer.
The text was updated successfully, but these errors were encountered: