Skip to content

Commit

Permalink
fix: try to autodetect the project_id
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Feb 15, 2024
1 parent 567cd9b commit f8e3c96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
10 changes: 9 additions & 1 deletion pytest_gee/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""A pytest plugin to build a GEE environment for a test session."""
from __future__ import annotations

import os
import uuid
from pathlib import Path

Expand All @@ -19,7 +20,14 @@ def gee_hash():
@pytest.fixture(scope="session")
def gee_folder_root():
"""Link to the root folder of the connected account."""
project_id = ee.data._cloud_api_user_project
# The credential information cannot be reached from
# the ee API as reported in https://issuetracker.google.com/issues/325020447
project_id = os.environ.get("EARTHENGINE_PROJECT", ee.data._cloud_api_user_project)
if project_id is None:
raise ValueError(
"The project name cannot be detected."
"Please set the EARTHENGINE_PROJECT environment variable."
)
return Path(f"projects/{project_id}/assets")


Expand Down
16 changes: 0 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Pytest session configuration."""
import os
from pathlib import Path

import ee
import pytest
Expand All @@ -13,20 +11,6 @@ def pytest_configure():
pytest_gee.init_ee_from_service_account()


# this fixture need override at the moment as the credential information cannot be reached from
# the ee API as reported in https://issuetracker.google.com/issues/325020447
@pytest.fixture(scope="session")
def gee_folder_root():
"""Link to the root folder of the connected account."""
project_id = os.environ.get("EARTHENGINE_PROJECT", ee.data._cloud_api_user_project)
if project_id is None:
raise ValueError(
"The project name cannot be detected."
"Please set the EARTHENGINE_PROJECT environment variable."
)
return Path(f"projects/{project_id}/assets")


@pytest.fixture(scope="session")
def gee_folder_structure():
"""Override the default test folder structure."""
Expand Down

0 comments on commit f8e3c96

Please sign in to comment.