Skip to content

Fix loading of json files for mapping #16

Description

@eloiferrer

The current cache functionality is based on loading a json file, which is different for staging and production.

This is currently defined through the function _load_entity_mappings:

def _load_entity_mappings() -> dict:

The problem is that this assumes that there is the WIKIBASE_HOST variable in the environment.
env = os.environ.get("WIKIBASE_HOST", "prod").lower()

This works from our containers defined in the staging and production environments but not if someone runs mardiclient locally and does not define a WIKIBASE_HOST variable.

In that case by default the mappings for production are loaded, even if the user might be connecting to the staging instance.

Possible fix

I suggest replacing the logic that uses WIKIBASE_HOST to distinguish between environments and use instead a variable that is already passed to create the MardiClient such as wikibase_url

wikibase_url = kwargs.pop("wikibase_url", config["WIKIBASE_URL"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions