Skip to content

Commit

Permalink
Issue #95 load_result: use result metadata URL iso job id
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Mar 22, 2023
1 parent 0a0139f commit 779355d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scripts/crossbackend-processing-poc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def main():
},
}

# backend_url = "openeocloud-dev.vito.be"
backend_url = "openeo.cloud"
backend_url = "openeocloud-dev.vito.be"
# backend_url = "openeo.cloud"

with TimingLogger(title=f"Connecting to {backend_url}", logger=_log):
connection = openeo.connect(url=backend_url).authenticate_oidc()
Expand Down
14 changes: 11 additions & 3 deletions src/openeo_aggregator/partitionedjobs/crossbackend.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import collections
import copy
import datetime
import functools
import itertools
import logging
import time
from typing import Callable, Dict, List, Sequence

import openeo
from openeo import BatchJob
from openeo.util import ContextTimer
from openeo_driver.jobregistry import JOB_STATUS

from openeo_aggregator.constants import JOB_OPTION_FORCE_BACKEND
Expand Down Expand Up @@ -137,9 +135,19 @@ def resolve_dependencies(
_log.info(
f"resolve_dependencies: replace placeholder {dep_id!r} with concrete {batch_job.job_id!r}"
)
try:
# Try to get "canonical" result URL (signed URL)
links = batch_job.get_results().get_metadata()["links"]
[result_url] = [k["href"] for k in links if k.get("rel") == "canonical"]
except Exception as e:
result_url = batch_job.get_results_metadata_url(full=True)
_log.warning(
f"Failed to get canonical result metadata URL for {batch_job.job_id!r}: {e}. "
f"Falling back on default result metadata URL {result_url!r}."
)
result[node_id] = {
"process_id": "load_result",
"arguments": {"id": batch_job.get_results_metadata_url(full=True)},
"arguments": {"id": result_url},
}
else:
result[node_id] = copy.deepcopy(node)
Expand Down

0 comments on commit 779355d

Please sign in to comment.