Skip to content

Javascript install through ee.install raised HTTP Error 404 and ee.require takes a long loading time #30

@suhendra0812

Description

@suhendra0812

Hi, all.
I encountered some issues when installing javascript module using ee.install. It raised HTTP Error 404: Not Found.

Downloading 'users/marcyinfeng/Algorithms:/mcd19_prior'...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\site-packages\eemont\extra.py", line 80, in install
    return ee_install(module, update, quiet)
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\site-packages\ee_extra\JavaScript\install.py", line 200, in install
    return _install_dependencies(x=deps, update=update, installed=[])
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\site-packages\ee_extra\JavaScript\install.py", line 188, in _install_dependencies
    _install(dep, update, quiet)
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\site-packages\ee_extra\JavaScript\install.py", line 158, in _install
    with urllib.request.urlopen(_convert_path_to_ee_sources(x)) as url:
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\WSBARATA01\miniconda3\envs\gee\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

It seems caused by the colon replacement which is insufficient for other cases. I found some javascript modules which have unusual path such as:
users/marcyinfeng/Algorithms:/mcd19_prior and users/marcyinfeng/Algorithms/:/S2_view_angle

def _convert_path_to_ee_sources(path: str) -> str:
    """Get the remote module path from the 'ee-sources' GCS bucket.

    Args:
        path: str

    Returns:
        An ee-sources module url.
    """
    if path.startswith("http"):
        eempath = path
    else:
        bpath = path.replace(":", "/") # <- insufficient replacement
        eempath = f"https://storage.googleapis.com/ee-sources/{bpath}"
    return eempath

I try to normalize the path using pathlib as follows:

def _convert_path_to_ee_sources(path: str) -> str:
    """Get the remote module path from the 'ee-sources' GCS bucket.

    Args:
        path: str

    Returns:
        An ee-sources module url.
    """
    if path.startswith("http"):
        eempath = path
    else:
        bpath = str(pathlib.Path(path.replace(":", "/"))).replace("\\", "/") # <- fix my issue, but only for Windows case
        eempath = f"https://storage.googleapis.com/ee-sources/{bpath}"
    return eempath

All dependencies were installed successfully:

The module 'users/marcyinfeng/utils:SIAC' is already installed!
Checking dependencies for users/marcyinfeng/utils:SIAC...
The module 'users/marcyinfeng/Algorithms:S2_MT_Cloud' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms:S2_MT_Cloud...
The module 'users/marcyinfeng/Algorithms:NN_cloud' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms:NN_cloud...
The module 'users/marcyinfeng/Algorithms:/mcd19_prior' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms:/mcd19_prior...
The module 'users/marcyinfeng/Algorithms:/get_aot' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms:/get_aot...
The module 'users/marcyinfeng/Algorithms/:/S2_view_angle' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms/:/S2_view_angle...
The module 'users/marcyinfeng/Algorithms/:/landsat_view_angles' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms/:/landsat_view_angles...
The module 'users/marcyinfeng/Algorithms/:/NN_prosail' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms/:/NN_prosail...
The module 'users/marcyinfeng/Algorithms/:/get_xps' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms/:/get_xps...
The module 'users/marcyinfeng/utils/:/load_NN' is already installed!
Checking dependencies for users/marcyinfeng/utils/:/load_NN...
The module 'users/gena/packages:palettes' is already installed!
Checking dependencies for users/gena/packages:palettes...
The module 'users/marcyinfeng/Algorithms/:/simu_ref' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms/:/simu_ref...
The module 'users/marcyinfeng/Algorithms:mcd19_prior' is already installed!
Checking dependencies for users/marcyinfeng/Algorithms:mcd19_prior...
The module 'users/gena/packages:text' is already installed!
Checking dependencies for users/gena/packages:text...
All dependencies were successfully installed!

But it takes a long time when loading the module using ee.require. Is it depend on how many other dependent modules?

Please, fixed this issue if possible. Thank you in advance.

Best regards,
Suhendra

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