Hi, 

I have seen there is a toolbox function for this purpose: https://cds.climate.copernicus.eu/toolbox/doc/tools/cdstoolbox.cdm.external_retrieve.html#cdstoolbox.cdm.external_retrieve

However, It does not seem to work with: url="https://www.unidata.ucar.edu/software/netcdf/examples/sresa1b_ncar_ccsm3-example.nc" which is the same you are using in documentation examples like: How to call a service with the CDS API

The app:

import cdstoolbox as ct

@ct.application(title='Download data')
@ct.output.download()
def download_application():
    data = ct.cdm.external_retrieve(
        url="https://www.unidata.ucar.edu/software/netcdf/examples/sresa1b_ncar_ccsm3-example.nc",
        obs=False
    )
    print(data)
    return data

The error: 

Traceback (most recent call last):
  File "/opt/cdstoolbox/cdscompute/cdscompute/cdshandlers/services/handler.py", line 59, in handle_request
    result = cached(context.method, proc, context, context.args, context.kwargs)
  File "/opt/cdstoolbox/cdscompute/cdscompute/caching.py", line 108, in cached
    result = proc(context, *context.args, **context.kwargs)
  File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 124, in __call__
    return p(*args, **kwargs)
  File "/opt/cdstoolbox/cdscompute/cdscompute/services.py", line 60, in __call__
    return self.proc(context, *args, **kwargs)
  File "/home/cds/cdsservices/services/cdm/external_retrieve.py", line 42, in external_retrieve
    raise ValueError("URL is not allowed")
ValueError: URL is not allowed

Could you provide a working example of this functionality?

Thank you beforehand,

Antonio Pérez

1 Comment

  1. Hi Antonio,

    Currently this functionality is normally restricted to 'internal' CDS developers only i.e. users cannot access arbitrary external files from the Toolbox,

    Thanks

    Kevin