Ejemplo n.º 1
0
    def _handler(self, request, response):
        try:
            wfdata = request.inputs["workflow"][0].data
            LOGGER.debug(f"type wfdata={type(wfdata)}, wfdata={wfdata}")
            # print(f"type wfdata={type(wfdata)}, wfdata={wfdata}")
            # workaround for CDATA issue in pywps
            # wfdata = wfdata.replace("<![CDATA[", "").replace("]]>", "")
            wf = workflow.WorkflowRunner(output_dir=self.workdir)
            file_uris = wf.run(wfdata)
        except Exception as e:
            raise ProcessError(f"{e}")

        # Metalink document with collection of netcdf files
        # ml4 = MetaLink4(
        #     "workflow-result", "Workflow result as NetCDF files.", workdir=self.workdir
        # )

        ml4 = build_metalink(
            "workflow-result",
            "Workflow result as NetCDF files.",
            self.workdir,
            file_uris,
        )

        # for ncfile in output:
        #     mf = MetaFile("NetCDF file", "NetCDF file", fmt=FORMATS.NETCDF)
        #     mf.file = ncfile
        #     ml4.append(mf)

        response.outputs["output"].data = ml4.xml
        response.outputs["prov"].file = wf.provenance.write_json()
        response.outputs["prov_plot"].file = wf.provenance.write_png()

        return response
Ejemplo n.º 2
0
def test_run_wf_cmip6_subset_average(tmp_path):
    wfdoc = resource_file("wf_cmip6_subset_average.json")
    wf = workflow.WorkflowRunner(output_dir=tmp_path)
    output = wf.run(wfdoc)
    assert (
        "rlds_Amon_IPSL-CM6A-LR_historical_r1i1p1f1_gr_19850101-20140101_avg-year.nc"
        in output[0])
Ejemplo n.º 3
0
 def _handler(self, request, response):
     wf = workflow.WorkflowRunner(
         data_root_dir=configuration.get_config_value(
             "data", "cmip5_archive_root"),
         output_dir=self.workdir)
     output = wf.run(request.inputs['workflow'][0].file)
     response.outputs['output'].file = output[0]
     return response
Ejemplo n.º 4
0
def test_wf_average_latlon_cmip6(tmp_path):
    wfdoc = resource_file("wf_average_latlon_cmip6.json")
    wf = workflow.WorkflowRunner(output_dir=tmp_path)
    output = wf.run(wfdoc)
    # print(output)
    assert (
        "rlds_Amon_IPSL-CM6A-LR_historical_r1i1p1f1_gr_19850116-20141216_avg-xy.nc"
        in output[0])
Ejemplo n.º 5
0
def test_wf_c3s_cmip6_original_files(tmp_path):
    wfdoc = resource_file("wf_c3s_cmip6_subset_original_files.json")
    wf = workflow.WorkflowRunner(output_dir=tmp_path)
    output = wf.run(wfdoc)
    expected_url = (
        "https://data.mips.copernicus-climate.eu/thredds/fileServer/esg_c3s-cmip6/"
        "CMIP/SNU/SAM0-UNICON/historical/r1i1p1f1/day/pr/gn/v20190323/"
        "pr_day_SAM0-UNICON_historical_r1i1p1f1_gn_18500101-18501231.nc")
    assert expected_url in output
Ejemplo n.º 6
0
 def _handler(self, request, response):
     try:
         wf = workflow.WorkflowRunner(output_dir=self.workdir)
         output = wf.run(request.inputs['workflow'][0].file)
     except Exception as e:
         raise ProcessError(f"{e}")
     # metalink document with collection of netcdf files
     ml4 = MetaLink4('workflow-result',
                     'Workflow result as NetCDF files.',
                     workdir=self.workdir)
     for ncfile in output:
         mf = MetaFile('NetCDF file', 'NetCDF file', fmt=FORMATS.NETCDF)
         mf.file = ncfile
         ml4.append(mf)
     response.outputs['output'].data = ml4.xml
     return response
Ejemplo n.º 7
0
def test_workflow_runner_simple():
    wf = workflow.WorkflowRunner(data_root_dir=CMIP5_ARCHIVE_ROOT,
                                 output_dir=tempfile.mkdtemp())
    output = wf.run(SIMPLE_WF)
    assert 'output.nc' in output[0]
Ejemplo n.º 8
0
def test_run_tree_wf_5(tmp_path):
    wf = workflow.WorkflowRunner(output_dir=tmp_path)
    output = wf.run(TREE_WF_5)
    assert (
        "rlds_Amon_IPSL-CM6A-LR_historical_r1i1p1f1_gr_19950101-20000101_avg-year.nc"
        in output[0])
Ejemplo n.º 9
0
def test_run_tree_wf_2(tmp_path):
    wf = workflow.WorkflowRunner(output_dir=tmp_path)
    output = wf.run(TREE_WF_2)
    assert "tas_mon_HadGEM2-ES_rcp85_r1i1p1_20900101-21000101_avg-year.nc" in output[
        0]
Ejemplo n.º 10
0
def test_workflow_runner_simple():
    wf = workflow.WorkflowRunner(
        output_dir=tempfile.mkdtemp())
    output = wf.run(SIMPLE_WF)
    assert 'tas_mon_HadGEM2-ES_rcp85_r1i1p1_20850116-21201216.nc' in output[0]