Skip to content
Snippets Groups Projects
Commit 5e40f3a9 authored by Alex Rojas's avatar Alex Rojas
Browse files

small updates

parent 639c7f4d
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:25172537-794b-4135-bb28-63c0fcefbb68 tags:
``` python
import os
import re
print(os.getcwd())
from maap.maap import MAAP
# maap = MAAP(maap_host='api.maap-project.org')
maap = MAAP(maap_host='api.maap-project.org')
```
%% Output
/projects/biomass-gedi-conus/src/biomass-gedi-conus/notebooks
Unable to load config file from source maap.cfg
Unable to load config file from source ./maap.cfg
Unable to load config file from source /projects/maap.cfg
%% Cell type:code id:b39e76ac-d765-4b8c-baf1-fe41f3296de9 tags:
``` python
l1b_urls_fpath = "../GEDI-L1B-2021-URLS.txt"
l2a_urls_fpath = "../GEDI-L2A-2021-URLS.txt"
with open(l1b_urls_fpath) as f:
l1b_fpaths = f.readlines()
with open(l2a_urls_fpath) as f:
l2a_fpaths = f.readlines()
# Get matching string pattern and run main.py
jobs_list = []
counter=1
for l1b_fp in l1b_fpaths:
# Get string pattern
str_pattern = re.findall("[0-9]{13}", os.path.basename(l1b_fp))[0]
try:
l2a_fp = [s for s in l2a_fpaths if str_pattern in s][0]
except:
print("No matching L2 file!", l1b_fp)
continue
print(l1b_fp)
print(l2a_fp)
job = maap.submitJob(identifier="single file test run",
algo_id="arojas_biomass_gedi_conus",
version="master",
username="arojearthdata",
queue="null",
L1B_URL=l1b_fp,
L2A_URL=l2a_fp)
jobs_list.append(job)
if counter%20:
print("on file num: ", counter)
counter+=1
break
```
%% Output
https://e4ftl01.cr.usgs.gov//GEDI_L1_L2/GEDI/GEDI01_B.002/2021.05.31/GEDI01_B_2021151223415_O13976_02_T00676_02_005_02_V002.h5
https://e4ftl01.cr.usgs.gov//GEDI_L1_L2/GEDI/GEDI02_A.002/2021.05.31/GEDI02_A_2021151223415_O13976_02_T00676_02_003_02_V002.h5
on file num: 1
%% Cell type:code id:8f0b9f73-ffb1-40b7-be0e-b31480571a4a tags:
``` python
print(jobs_list[:2])
```
%% Output
[{'job_id': '8c3396a7-500b-4b55-ad25-ca8c0fcfe1da', 'status': 'Accepted', 'machine_type': None, 'architecture': None, 'machine_memory_size': None, 'directory_size': None, 'operating_system': None, 'job_start_time': None, 'job_end_time': None, 'job_duration_seconds': None, 'cpu_usage': None, 'cache_usage': None, 'mem_usage': None, 'max_mem_usage': None, 'swap_usage': None, 'read_io_stats': None, 'write_io_stats': None, 'sync_io_stats': None, 'async_io_stats': None, 'total_io_stats': None, 'error_details': None, 'response_code': 200, 'outputs': []}]
%% Cell type:code id:7fe1c6f4-37c5-4fe7-b9ff-51e17b7a5cf0 tags:
``` python
# View job status
for job in jobs_list:
print(job.retrieve_status())
print(job.id)
break
```
%% Output
Accepted
8c3396a7-500b-4b55-ad25-ca8c0fcfe1da
%% Cell type:code id:873e9ea7-d6cb-4bb9-b082-5bffb4026615 tags:
``` python
# Retrieve results
for job in jobs_list:
print(job.retrieve_result())
break
```
%% Output
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[12], line 3
1 # Retrieve results
2 for job in jobs_list:
----> 3 print(job.retrieve_result())
4 break
File /maap-py/maap/dps/dps_job.py:98, in DPSJob.retrieve_result(self)
92 logger.debug(headers)
93 response = requests.get(
94 url=url,
95 verify=self.__not_self_signed,
96 headers=headers
97 )
---> 98 self.set_job_results_result(RequestsUtils.check_response(response))
99 return self.outputs
File /maap-py/maap/utils/requests_utils.py:25, in RequestsUtils.check_response(dps_response)
22 @staticmethod
23 def check_response(dps_response):
24 if dps_response.status_code not in [200, 201]:
---> 25 raise RuntimeError('response is not 200 or 201. code: {}. details: {}'.format(dps_response.status_code,
26 dps_response.content))
27 return dps_response.content.decode('UTF-8')
RuntimeError: response is not 200 or 201. code: 500. details: b'<ows:ExceptionReport xmlns:wps="http://www.opengis.net/wps/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:schemaLocation="http://schemas.opengis.net/wps/2.0/wps.xsd" xmlns:ows="http://www.opengis.net/ows/2.0"><ows:Exception exceptionCode="FailedGetResult" locator="GetResult"><ows:ExceptionText>Failed to get job result of job with id: 8c3396a7-500b-4b55-ad25-ca8c0fcfe1da. Aborting retrieving information of job because status is job-queued. If you don\'t see expected results, please contact administrator of DPS</ows:ExceptionText></ows:Exception></ows:ExceptionReport>'
%% Cell type:code id:e8a40e13-dcdd-4b7f-a3b6-d060bb52eaf5 tags:
``` python
```
%% Cell type:code id:988420a0-1145-499c-927c-eec059c0dde9 tags:
``` python
```
%% Cell type:code id:31626d2a-4edf-4572-81c2-7b68080e2dd3 tags:
``` python
```
%% Cell type:code id:9ecb7ffc-319f-40c9-8f6e-d18b6ea1c890 tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment