Skip to content

SLD DB is down? #9

@andyfaff

Description

@andyfaff

There are failing tests in the refnx CI because there's probably something gone wrong with the SLD server. If there is no webaccess to the server it should probably fail more gracefully. Or, actually have a local copy of data files.

_______________________ TestStructure.test_to_from_orso ________________________

self = <orsopy.slddb.webapi.SLD_API object at 0x115568860>

    def check(self):
        # make sure the local database file is up to date, if not try to download newest version
        if self.first_access:
            now = datetime.datetime.now()
            try:
>               stat = pathlib.Path(DB_FILE).stat()
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/slddb/webapi.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = PosixPath('/Users/runner/.config/slddb/local_database.db')

    def stat(self, *, follow_symlinks=True):
        """
        Return the result of the stat() system call on this path, like
        os.stat() does.
        """
>       return os.stat(self, follow_symlinks=follow_symlinks)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       FileNotFoundError: [Errno 2] No such file or directory: '/Users/runner/.config/slddb/local_database.db'

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pathlib.py:840: FileNotFoundError

During handling of the above exception, another exception occurred:

self = <refnx.reflect.tests.test_structure.TestStructure object at 0x112438d10>

    def test_to_from_orso(self):
        # orso model language serialisation
        air = SLD(0)
        sio2 = MaterialSLD("SiO2", 2.2, name="SiO2")
        si = SLD(2.07)
    
        s = air | sio2(15, 3) | si(0, 4)
        mls = s.to_orso()
        dct = mls.to_dict()
    
        sample_model = SampleModel(**dct)
        s2 = Structure.from_orso(sample_model)
        assert_allclose(s2[-1].rough.value, s[-1].rough.value)
        assert_allclose(s2[1].rough.value, s[1].rough.value)
        assert_allclose(s2[1].thick.value, s[1].thick.value)
    
>       s = Structure.from_orso(self.pth / "sample_model_example_2.yml")
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/refnx/reflect/tests/test_structure.py:647: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/refnx/reflect/structure.py:891: in from_orso
    layers = sample_model.resolve_to_layers()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/fileio/model_language.py:364: in resolve_to_layers
    sub_layers = obj.resolve_to_layers()
                 ^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/fileio/model_language.py:181: in resolve_to_layers
    layers[i + added].material.generate_density()
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/fileio/model_building_blocks.py:95: in generate_density
    dens = ri.resolve_formula(formula)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/utils/resolver_slddb.py:43: in resolve_formula
    res = api.search(formula=formula)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/slddb/webapi.py:116: in search
    self.check()
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/slddb/webapi.py:60: in check
    self.download_db()
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/orsopy/slddb/webapi.py:80: in download_db
    res = request.urlopen(WEBAPI_URL + self.db_suburl, context=context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py:215: in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py:521: in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py:630: in http_response
    response = self.parent.error(
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py:559: in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py:492: in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <urllib.request.HTTPDefaultErrorHandler object at 0x114f6c410>
req = <urllib.request.Request object at 0x1156b2300>
fp = <http.client.HTTPResponse object at 0x1151d2470>, code = 503
msg = 'Service Unavailable'
hdrs = <http.client.HTTPMessage object at 0x115237890>

    def http_error_default(self, req, fp, code, msg, hdrs):
>       raise HTTPError(req.full_url, code, msg, hdrs, fp)
E       urllib.error.HTTPError: HTTP Error 503: Service Unavailable

/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/urllib/request.py:639: HTTPError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions