UP42 Python SDK

repository·master·Indexed 40 days ago

https://github.com/up42/up42-py

A Python library for ordering, accessing, and analyzing Earth Observation (EO) data through the UP42 geospatial marketplace and developer platform. Version 4.2.0a1 includes tools for client instantiation, OAuth authentication, and credential management.

Tokens
1.9K
Snippets
13
Records
15
Agent score
50%

What's inside UP42

  1. Access UP42 SDK documentation and resources

    master

    The following resources are available for developers using the UP42 Python SDK:

    • Reference: Detailed API documentation.
    • Release notes: History of changes and updates.
    • Authentication: Guides on how to authenticate your requests.
    • Quick start: Step-by-step instructions to get started with the SDK.
  2. Preview documentation locally with live reload

    master

    You can preview the documentation locally using mkdocs. This command starts a local server that automatically reloads when you make changes to the documentation files. The site is typically accessible at http://127.0.0.1:8000/.

    make serve
  3. Install dependencies for documentation development

    master

    To set up a local environment for developing and previewing the up42-py documentation, navigate to the docs directory and use poetry to install only the documentation-specific dependencies.

    cd docs
    poetry install --only docs
  4. Build the documentation site

    master
    To generate a static version of the documentation site, use the mkdocs build command. Note that using make serve is generally preferred for active development as it provides live reloading.
    mkdocs build
  5. Run tests with pytest

    master

    Testing is managed via pytest. Ensure you have run poetry install to include testing dependencies.

    To run all tests located in the tests/ directory, execute:

    poetry run pytest

    If using PyCharm, you can right-click the tests/ folder or a specific test file and select Run 'pytest in tests' to use the Poetry-managed environment.

  6. Configure pre-commit hooks for code quality

    master

    The project uses pre-commit to enforce code quality (formatting, linting, and type checking) before commits.

    To install the hooks so they run automatically on every commit, use:

    poetry run pre-commit install

    To run all hooks manually against all files in the repository, use:

    poetry run pre-commit run --all-files
  7. Publish documentation to GitHub Pages

    master
    To publish the updated documentation to GitHub Pages, use the make gh-deploy command. This will push the built site to the gh-deploy branch and trigger a republishing of the site.
    make gh-deploy
  8. Install the UP42 SDK for development

    master

    To set up a development environment for the UP42 SDK, clone the repository and use asdf to manage Python and Poetry versions. Once the environment is initialized via asdf install, use poetry install to create a virtual environment and install all project dependencies defined in pyproject.toml.

    git clone git@github.com:up42/up42-py.git
    cd up42-py
    
    # Using asdf to set up the environment
    asdf plugin-add python
    asdf plugin-add poetry
    asdf install
    
    # Install dependencies via Poetry
    poetry install
  9. Reference: Environment Variables

    master

    The following environment variable is available for configuring SDK behavior during development.

    | VARIABLE NAME               | DESCRIPTION                                                                 |
    |-----------------------------|-----------------------------------------------------------------------------|
    | UP42_DISABLE_VERSION_CHECK  | Set to `True` to skip the automatic SDK version check. Defaults to `False`. |
  10. Initialize the UP42 Client using create()

    master

    The create function is the primary way to instantiate a Client. It automates the process of detecting credentials from multiple sources, setting up a token retriever, and creating an authenticated HTTP session.

    To use it, provide a list of credential sources (such as dictionaries containing username and password), the token_url for OAuth authentication, and optional factory functions for customization.

    If no valid credentials are found across the provided sources, it raises MissingCredentials. If multiple conflicting credential sources are detected, it raises MultipleCredentialsSources.

    from up42.http import client
    
    # Example usage with explicit credentials
    credential_sources = [{"username": "my_user", "password": "my_password"}]
    token_url = "https://auth.up42.com/token"
    
    up42_client = client.create(
        credential_sources=credential_sources,
        token_url=token_url
    )
    
    # up42_client is an instance of Client and can be used for API requests