Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #19 Drop unused capfd logic to simplify auth setup in CI (#9) #29

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 8 additions & 29 deletions src/openeo_gfmap/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
from dataclasses import dataclass
from enum import Enum
from typing import Callable, Dict, Optional
from typing import Callable, Dict

import openeo

Expand All @@ -29,7 +29,7 @@ class BackendContext:
backend: Backend


def vito_connection(capfd: Optional = None) -> openeo.Connection:
def vito_connection() -> openeo.Connection:
"""Performs a connection to the VITO backend using the oidc authentication."""
# Note: this generic `authenticate_oidc()` call allows both:
# - device code/refresh token based authentication for manual test
Expand All @@ -39,42 +39,21 @@ def vito_connection(capfd: Optional = None) -> openeo.Connection:
# See https://open-eo.github.io/openeo-python-client/auth.html#oidc-authentication-dynamic-method-selection # NOQA
# and Jenkinsfile, where Jenkins fetches the env vars from VITO TAP Vault.
connection = openeo.connect("openeo.vito.be")

if capfd is not None:
with capfd.disabled():
# Temporarily disable output capturing, to make sure that OIDC device
# code instructions (if any) are shown.
connection.authenticate_oidc()
else:
connection.authenticate_oidc()
connection.authenticate_oidc()
return connection


def cdse_connection(capfd: Optional = None) -> openeo.Connection:
def cdse_connection() -> openeo.Connection:
"""Performs a connection to the CDSE backend using oidc authentication."""
connection = openeo.connect(
"https://openeo.dataspace.copernicus.eu/openeo/1.2"
)
if capfd is not None:
with capfd.disabled():
# Temporarily disable output capturing, to make sure that OIDC device
# code instructions (if any) are shown.
connection.authenticate_oidc()
else:
connection.authenticate_oidc()
connection = openeo.connect("https://openeo.dataspace.copernicus.eu/openeo/1.2")
connection.authenticate_oidc()
return connection


def eodc_connection(capfd: Optional = None) -> openeo.Connection:
def eodc_connection() -> openeo.Connection:
"""Perfroms a connection to the EODC backend using the oidc authentication."""
connection = openeo.connect("https://openeo.eodc.eu/openeo/1.1.0")
if capfd is not None:
with capfd.disabled():
# Temporarily disable output capturing, to make sure that OIDC device
# code instructions (if any) are shown.
connection.authenticate_oidc()
else:
connection.authenticate_oidc()
connection.authenticate_oidc()
return connection


Expand Down
Loading