diff --git a/.github/.backend_git_ref b/.github/.backend_git_ref index ba2906d0..268bd085 100644 --- a/.github/.backend_git_ref +++ b/.github/.backend_git_ref @@ -1 +1 @@ -main +35bae875265258dfacb8c9103e6967c7c934406a \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a9180e5..6b8c72d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ on: jobs: check: - uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@main + uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@ubuntu-24 strategy: fail-fast: false @@ -28,7 +28,7 @@ jobs: # Checks the library using minimum version resolution # `uv` has this feature built-in, c.f. https://github.com/astral-sh/uv check-min-version: - uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@main + uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@ubuntu-24 with: python-version: 3.9 diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 86b67e40..0ab5dd8d 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -18,18 +18,8 @@ on: jobs: check: - runs-on: ubuntu-22.04 - - services: - postgres: - image: postgis/postgis - env: - POSTGRES_USER: geoengine - POSTGRES_PASSWORD: geoengine - POSTGRES_DB: geoengine - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + runs-on: ubuntu-24.04 + container: quay.io/geoengine/devcontainer:latest defaults: run: @@ -46,9 +36,9 @@ jobs: echo "GEOENGINE_VERSION=$(cat .github/.backend_git_ref)" >> $GITHUB_OUTPUT if ${{ inputs.use-uv }}; then echo "PIP_INSTALL=uv pip install --resolution=lowest-direct" >> $GITHUB_OUTPUT - echo "VENV_CALL=source .venv/bin/activate" >> $GITHUB_OUTPUT + echo "VENV_CALL=. .venv/bin/activate" >> $GITHUB_OUTPUT else - echo "PIP_INSTALL=pip install" >> $GITHUB_OUTPUT + echo "PIP_INSTALL=python -m pip install" >> $GITHUB_OUTPUT echo "VENV_CALL=" >> $GITHUB_OUTPUT fi if ${{ inputs.coverage }}; then @@ -62,28 +52,6 @@ jobs: repository: geo-engine/geoengine ref: ${{ steps.vars.outputs.GEOENGINE_VERSION }} path: backend - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: true - android: true - dotnet: true - haskell: true - large-packages: true - docker-images: true - swap-storage: true - - name: Install lld & GDAL & Protobuf - run: | - sudo apt-get update - sudo apt-get install lld libgdal-dev gdal-bin build-essential clang curl protobuf-compiler libgeos-dev libproj-dev - sudo apt-get clean - export C_INCLUDE_PATH=/usr/include/gdal:$C_INCLUDE_PATH - export CPLUS_INCLUDE_PATH=/usr/include/gdal:$CPLUS_INCLUDE_PATH - sudo ldconfig - - name: Install Rustup - run: | - curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y - echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH - name: Set up Python ${{ inputs.python-version }} uses: actions/setup-python@v4 with: @@ -93,7 +61,7 @@ jobs: - name: Setup UV and create venv if: ${{ inputs.use-uv }} run: | - pip install uv + python -m pip install uv uv venv - name: Install build dependencies run: | @@ -133,16 +101,23 @@ jobs: python -m mypy tests - name: Test run: | + service postgresql start ${{ steps.vars.outputs.VENV_CALL }} pytest ${{ steps.vars.outputs.COVERAGE_COMMAND }} env: GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend GEOENGINE_TEST_BUILD_TYPE: "release" - - name: Upload coverage to Coveralls + - name: Report coverage to Coveralls if: ${{ inputs.coverage }} - uses: coverallsapp/github-action@v2 - with: - base-path: library + # 1. We need to adjust the paths in the lcov file to match the repository structure. + # 2. We need to download the coveralls script and upload the report. + run: | + sed -i 's|SF:geoengine/|SF:|' ../coverage.lcov + curl -sL https://coveralls.io/coveralls-linux.tar.gz | tar -xz && ./coveralls report ../coverage.lcov + # If we don't run it in the code folder, the paths in the report will prefixed with `library/geoengine/`. + working-directory: library/geoengine + env: + COVERALLS_REPO_TOKEN: ${{ github.token }} - name: Examples run: | ${{ steps.vars.outputs.VENV_CALL }} diff --git a/examples/layers.ipynb b/examples/layers.ipynb index a9957d98..72fffe15 100644 --- a/examples/layers.ipynb +++ b/examples/layers.ipynb @@ -151,7 +151,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -196,7 +196,7 @@ } ], "source": [ - "test_collection = root_of_layerdb.items[1].load()\n", + "test_collection = root_of_layerdb.items[0].load()\n", "test_collection" ] }, @@ -1162,7 +1162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.12" + "version": "3.12.3" }, "orig_nbformat": 4, "vscode": { diff --git a/geoengine/__init__.py b/geoengine/__init__.py index af2ff8b9..9dca56c0 100644 --- a/geoengine/__init__.py +++ b/geoengine/__init__.py @@ -1,11 +1,11 @@ '''Entry point for Geo Engine Python Library''' -from pkg_resources import get_distribution from requests import utils from pydantic import ValidationError from geoengine_openapi_client.exceptions import BadRequestException, OpenApiException, ApiTypeError, ApiValueError, \ ApiKeyError, ApiAttributeError, ApiException, NotFoundException from geoengine_openapi_client import UsageSummaryGranularity +import geoengine_openapi_client from . import workflow_builder from .raster_workflow_rio_writer import RasterWorkflowRioWriter @@ -39,7 +39,7 @@ add_or_replace_dataset_with_permissions, dataset_info_by_name -DEFAULT_USER_AGENT = f'geoengine-python/{get_distribution("geoengine").version}' +DEFAULT_USER_AGENT = f'geoengine-python/{geoengine_openapi_client.__version__}' def default_user_agent(_name="python-requests"): diff --git a/geoengine/auth.py b/geoengine/auth.py index f0cfb252..d4e4dd49 100644 --- a/geoengine/auth.py +++ b/geoengine/auth.py @@ -8,7 +8,6 @@ import os from dotenv import load_dotenv -from pkg_resources import get_distribution from requests.auth import AuthBase import urllib3 @@ -71,7 +70,7 @@ def __init__(self, # Auto-generated SessionApi cannot handle dynamically differing return types (SimpleSession or UserSession). # Because of that requests must be send manually. http = urllib3.PoolManager() - user_agent = f'geoengine-python/{get_distribution("geoengine").version}' + user_agent = f'geoengine-python/{geoengine_openapi_client.__version__}' if credentials is not None: session = http.request( diff --git a/tests/test_auth.py b/tests/test_auth.py index 969e7487..3a172d3b 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -3,7 +3,7 @@ from datetime import datetime import unittest import os -from pkg_resources import get_distribution +import geoengine_openapi_client import geoengine as ge from geoengine.error import GeoEngineException from geoengine.types import QueryRectangle @@ -120,7 +120,7 @@ def test_initialize_env(self): def test_user_agent(self): with UrllibMocker() as m: m.post('http://mock-instance/anonymous', - request_headers={'User-Agent': f'geoengine-python/{get_distribution("geoengine").version}'}, + request_headers={'User-Agent': f'geoengine-python/{geoengine_openapi_client.__version__}'}, json={ "id": "e327d9c3-a4f3-4bd7-a5e1-30b26cae8064", "user": None, diff --git a/tests/test_wfs.py b/tests/test_wfs.py index 974bb1ce..09a53d04 100644 --- a/tests/test_wfs.py +++ b/tests/test_wfs.py @@ -8,7 +8,7 @@ import geopandas as gpd import geopandas.testing # pylint: disable=unused-import from shapely.geometry import Point -from pkg_resources import get_distribution +import geoengine_openapi_client import geoengine as ge from . import UrllibMocker @@ -829,7 +829,7 @@ def test_owslib_user_agent(self): }] }, request_headers={'Authorization': 'Bearer e327d9c3-a4f3-4bd7-a5e1-30b26cae8064', - 'User-Agent': f'geoengine/openapi-client/python/{get_distribution("geoengine-openapi-client").version}'} + 'User-Agent': f'geoengine/openapi-client/python/{geoengine_openapi_client.__version__}'} ) ge.initialize("http://mock-instance")