Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] first "import cocopp" bails without internet connection #2020

Closed
nikohansen opened this issue Sep 28, 2021 · 2 comments
Closed
Labels

Comments

@nikohansen
Copy link
Contributor

nikohansen commented Sep 28, 2021

when called for a first time on a computer, because the archiving module is trying to setup the official archives

In [2]: import cocopp
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
<ipython-input-2-b18a250e2bf1> in <module>
----> 1 import cocopp

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/__init__.py in <module>
    100 from numpy.random import seed as set_seed
    101 
--> 102 from .cococommands import *  # outdated
    103 from . import config
    104 from . import archiving

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/cococommands.py in <module>
     61 from __future__ import absolute_import
     62 
---> 63 from .pproc import DataSetList as _DataSetList
     64 from .toolsdivers import StringList as _StringList
     65 from .archiving import official_archives

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/pproc.py in <module>
     40 from .readalign import HArrayMultiReader, VArrayMultiReader, alignArrayData
     41 from .ppfig import consecutiveNumbers, Usage
---> 42 from . import archiving
     43 
     44 do_assertion = genericsettings.force_assertions # expensive assertions

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/archiving.py in <module>
   1381 official_archives = OfficialArchives()
   1382 # TODO-decide: when should we (try to) update these?
-> 1383 official_archives.set_as_attributes_in()  # set "official" archives as attributes by suite name
   1384 
   1385 class _ArchivesOfficial(ListOfArchives):

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/archiving.py in set_as_attributes_in(self, target, except_for, update)
   1323             if name not in except_for:
   1324                 setattr(target or self, name.replace('-', '_'),
-> 1325                         get(name).update() if update else get(name))
   1326         return self
   1327 

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/archiving.py in get(url_or_folder)
    307     if (url_or_folder.lower().startswith("http")
    308         or url_or_folder in official_archives.names):
--> 309         return _get_remote(url_or_folder)
    310     return COCODataArchive(url_or_folder)
    311 

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/archiving.py in _get_remote(url, target_folder, redownload)
    245     if redownload or not os.path.exists(_definition_file_to_read(target_folder)):
    246         _makedirs(target_folder)
--> 247         _download_definitions(url, target_folder)
    248         _url_add(target_folder, url)
    249         if not official_archives.url(key) and not url in official_archives.urls.values():

~/opt/anaconda3/lib/python3.7/site-packages/cocopp-2.4.30-py3.7.egg/cocopp/archiving.py in _download_definitions(url, target_folder)
    217     """download definition file and sync url into it"""
    218     _urlretrieve(url + '/' + default_definition_filename,
--> 219                  _definition_file_to_write(target_folder))
    220     try:
    221         read_definition_file(_definition_file_to_read(target_folder))

~/opt/anaconda3/lib/python3.7/urllib/request.py in urlretrieve(url, filename, reporthook, data)
    245     url_type, path = splittype(url)
    246 
--> 247     with contextlib.closing(urlopen(url, data)) as fp:
    248         headers = fp.info()
    249 

~/opt/anaconda3/lib/python3.7/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
    220     else:
    221         opener = _opener
--> 222     return opener.open(url, data, timeout)
    223 
    224 def install_opener(opener):

~/opt/anaconda3/lib/python3.7/urllib/request.py in open(self, fullurl, data, timeout)
    529         for processor in self.process_response.get(protocol, []):
    530             meth = getattr(processor, meth_name)
--> 531             response = meth(req, response)
    532 
    533         return response

~/opt/anaconda3/lib/python3.7/urllib/request.py in http_response(self, request, response)
    639         if not (200 <= code < 300):
    640             response = self.parent.error(
--> 641                 'http', request, response, code, msg, hdrs)
    642 
    643         return response

~/opt/anaconda3/lib/python3.7/urllib/request.py in error(self, proto, *args)
    567         if http_err:
    568             args = (dict, 'default', 'http_error_default') + orig_args
--> 569             return self._call_chain(*args)
    570 
    571 # XXX probably also want an abstract factory that knows when it makes

~/opt/anaconda3/lib/python3.7/urllib/request.py in _call_chain(self, chain, kind, meth_name, *args)
    501         for handler in handlers:
    502             func = getattr(handler, meth_name)
--> 503             result = func(*args)
    504             if result is not None:
    505                 return result

~/opt/anaconda3/lib/python3.7/urllib/request.py in http_error_default(self, req, fp, code, msg, hdrs)
    647 class HTTPDefaultErrorHandler(BaseHandler):
    648     def http_error_default(self, req, fp, code, msg, hdrs):
--> 649         raise HTTPError(req.full_url, code, msg, hdrs, fp)
    650 
    651 class HTTPRedirectHandler(BaseHandler):

HTTPError: HTTP Error 404: Not Found
@nikohansen nikohansen added the bug label Sep 28, 2021
@nikohansen nikohansen changed the title [Bug report] "import cocopp" bails without internet connection [Bug report] first "import cocopp" bails without internet connection Oct 5, 2021
@nikohansen
Copy link
Contributor Author

Changing line 86 of the source code file cocopp/archiving.py in the Python local site packages folder of the system to

coco_url = "https://numbbo.github.io/data-archive"  # new data location

should be a quick fix.

@nikohansen
Copy link
Contributor Author

pip install --upgrade cocopp

should now fix this issue. If this does not install a newer version, use

pip uninstall cocopp --yes

first (possibly several times).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant