Skip to content

rs_server_prip/prip_retriever.md

<< Back to index

Create / cache an EODAG provider for a given PRIP station (s1a, s1c, s2a …).

Usage

provider = init_prip_provider("s1a")

init_prip_provider(station) cached

Initialize the prip provider for the given station.

It initializes an eodag provider for the given station. The EODAG configuration file is read from the path given in the EODAG_PRIP_CONFIG var env if set. It is read from the path config/prip_ws_config.yaml otherwise.

If the station is unknown or if the prip station configuration reading fails, a specific exception is raised to inform the caller of the issue.

Parameters:

Name Type Description Default
station str

the station to interact with.

required

Returns:

Type Description
EodagProvider

the EodagProvider initialized

Source code in docs/rs-server/services/prip/rs_server_prip/prip_retriever.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
@lru_cache
def init_prip_provider(station: str) -> EodagProvider:
    """Initialize the prip provider for the given station.

    It initializes an eodag provider for the given station.
    The EODAG configuration file is read from the path given in the EODAG_PRIP_CONFIG var env if set.
    It is read from the path config/prip_ws_config.yaml otherwise.

    If the station is unknown or if the prip station configuration reading fails,
    a specific exception is raised to inform the caller of the issue.

    Args:
        station (str): the station to interact with.

    Returns:
         the EodagProvider initialized

    """
    station = station.lower()

    try:
        # Get the prip_ws_config.yaml file path for eodag.
        # Check if the config file path is overriden in the environment variables
        eodag_config = Path(os.environ.get("EODAG_PRIP_CONFIG", DEFAULT_EODAG_CONFIG))

        # Read the station authentication from rs-server.yaml file or RSPY__TOKEN__xxx env vars
        ext_auth_config = load_external_auth_config(station, "prip")

        # default to eodag, default station "prip"
        return EodagProvider(ext_auth_config, eodag_config, station)

    except Exception as exc:
        raise CreateProviderFailed(f"Failed to setup EODAG for PRIP station {station}") from exc