Client GUI Usage¶
The following section shows how to use the Sen4CAP client's GUI using client.show_app() to open the GUI of the app,
and to interact with the returned app instance.
In [10]:
Copied!
import json
from pathlib import Path
from sen4cap_client.api import create_client
import json
from pathlib import Path
from sen4cap_client.api import create_client
Create a client instance¶
Important: Make sure you have already configured the client to run with the TAO Process API server. In a command shell run sen4cap-client configure. Leave all settings as suggested unless you are asked for your personal credentials. If this doesn't work for you, you can create a local config.json here. You could also use it to provide configuration overrides. For the possible configuration setting see here.
In [11]:
Copied!
config_path = Path("config.json")
if config_path.exists():
config = json.loads(config_path.read_text())
else:
config = {}
config_path = Path("config.json")
if config_path.exists():
config = json.loads(config_path.read_text())
else:
config = {}
Create a Sen4CAP client instance with your configuration, if any.
In [6]:
Copied!
client = create_client(**config)
client = create_client(**config)
Show the app¶
In [8]:
Copied!
# app = client.show_app(display="browser")
app = client.show_app(height=640)
# app = client.show_app(display="browser")
app = client.show_app(height=640)
In [13]:
Copied!
aoi_processor = app.process_requests["218"]
aoi_processor = app.process_requests["218"]
In [14]:
Copied!
aoi_processor.inputs["c30145a7-029c-4499-98bc-9903ca46531c"] = "2024-06-03"
aoi_processor.inputs["c30145a7-029c-4499-98bc-9903ca46531c"] = "2024-06-03"
In [15]:
Copied!
aoi_processor.inputs["472efeab-514a-4e15-9dba-d5812d653065"] = "2024-06-11"
aoi_processor.inputs["472efeab-514a-4e15-9dba-d5812d653065"] = "2024-06-11"
In [16]:
Copied!
aoi_processor.inputs["bed1920e-51c0-406e-b22e-70d1f86d95d4"] = (
"POLYGON (("
" 9.66 53.75,"
"10.38 53.75,"
"10.38 53.35,"
" 9.66 53.35,"
" 9.66 53.75"
"))"
)
aoi_processor.inputs["bed1920e-51c0-406e-b22e-70d1f86d95d4"] = (
"POLYGON (("
" 9.66 53.75,"
"10.38 53.75,"
"10.38 53.35,"
" 9.66 53.35,"
" 9.66 53.75"
"))"
)
In [20]:
Copied!
aoi_processor
aoi_processor
Out[20]:
{'inputs': {'c30145a7-029c-4499-98bc-9903ca46531c': '2024-06-03', '472efeab-514a-4e15-9dba-d5812d653065': '2024-06-11', '691adc8e-9bba-4f42-86e2-ccd72189edc3': 'NDVI', 'bed1920e-51c0-406e-b22e-70d1f86d95d4': 'POLYGON (( 9.66 53.75,10.38 53.75,10.38 53.35, 9.66 53.35, 9.66 53.75))'}, 'outputs': {'db96d3e8-0243-48dc-ac9a-6470d2c39eb8': {}}}
In [22]:
Copied!
app.serve_result
app.serve_result
Out[22]:
ServeResult(host='127.0.0.1', port=59723, server_url='http://127.0.0.1:59723', ws_url='ws://127.0.0.1:59723/ws', ui_base_url='http://127.0.0.1:59723', ui_url='http://127.0.0.1:59723?t=1784650481&ws=ws%3A%2F%2F127.0.0.1%3A59723%2Fws', app=<fastapi.applications.FastAPI object at 0x000001B4D8FACD70>, server=<uvicorn.server.Server object at 0x000001B4D8E582D0>, thread=<Thread(Thread-5 (run), started daemon 29580)>)
In [23]:
Copied!
data_array = client.open_job_result(job_id="654", asset_name="SNDVI")
data_array
data_array = client.open_job_result(job_id="654", asset_name="SNDVI")
data_array
C:\Users\norma\AppData\Local\Temp\ipykernel_32184\1514706264.py:1: ClientWarning: An error occurred while getting process description for process ID 'L3B AOI Indicators Processor 5.0.4' data_array = client.open_job_result(job_id="654", asset_name="SNDVI")
--------------------------------------------------------------------------- ExceptionGroup Traceback (most recent call last) ExceptionGroup: 2 of 2 possible openers failed (2 sub-exceptions) The above exception was the direct cause of the following exception: JobResultOpenError Traceback (most recent call last) Cell In[23], line 1 ----> 1 data_array = client.open_job_result(job_id="654", asset_name="SNDVI") 2 data_array File ~\Projects\sen4cap-client\.pixi\envs\default\Lib\site-packages\cuiman\api\client_mixin.py:153, in ClientMixin.open_job_result(self, job_id, output_name, data_type, media_type, poll_interval, timeout, **options) 142 ctx = JobResultOpenContext( 143 config=self.config, 144 job_id=job_id, (...) 150 options=options, 151 ) 152 opener_registry = self.config.get_job_result_opener_registry() --> 153 return run_sync( 154 open_job_result, 155 ctx, 156 *opener_registry.opener_types, 157 ) File ~\Projects\sen4cap-client\.pixi\envs\default\Lib\site-packages\gavicore\util\runsync.py:78, in run_sync(async_fn, *args, **kwargs) 74 future = asyncio.run_coroutine_threadsafe(coro, loop) 76 # Block synchronously until done. 77 # If the coroutine raises, .result() re-raises the same exception here. ---> 78 return future.result() File ~\Projects\sen4cap-client\.pixi\envs\default\Lib\concurrent\futures\_base.py:454, in Future.result(self, timeout) 452 raise CancelledError() 453 elif self._state == FINISHED: --> 454 return self.__get_result() 455 else: 456 raise TimeoutError() File ~\Projects\sen4cap-client\.pixi\envs\default\Lib\concurrent\futures\_base.py:396, in Future.__get_result(self) 394 if self._exception is not None: 395 try: --> 396 raise self._exception 397 finally: 398 # Break a reference cycle with the exception in self._exception 399 self = None File ~\Projects\sen4cap-client\.pixi\envs\default\Lib\site-packages\cuiman\api\opener\opener.py:128, in open_job_result(ctx, *opener_types) 126 raise JobResultOpenError("No job result opener found") 127 error_messages = "\n".join(f"* {t.__name__}: {e}" for t, e in errors) --> 128 raise JobResultOpenError( 129 f"Job result opener failure:\n{error_messages}" 130 ) from ExceptionGroup( 131 f"{len(errors)} of {accepted_opener_count} possible opener" 132 f"{'' if accepted_opener_count == 1 else 's'} failed", 133 [e for _, e in errors], 134 ) JobResultOpenError: Job result opener failure: * Sen4CAPJobResultsOpener: HTTP response code: 404 * XarrayDatasetOpener: found the following matches with the input file in xarray's IO backends: ['netcdf4']. But their dependencies may not be installed, see: https://docs.xarray.dev/en/stable/user-guide/io.html https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
In [ ]:
Copied!