For AI agents: the complete documentation index is available at https://docs.dataplatform.ovh.net/llms.txt, the full documentation bundle is available at https://docs.dataplatform.ovh.net/llms-full.txt, and this page is available as Markdown at https://docs.dataplatform.ovh.net/developers-python-sdk-git.md.
  • 🇬🇧 English
  • Use custom Python modules from a Git repository

    In some cases, you will want to use your own and already existing Python code

    Objective

    In some cases, you will want to use your own and already existing Python code.

    In order to import your custom Python modules and use it in a Custom action, you may refer to an external Git repository that will be pulled before each build of your job.

    Here are the steps in order to use an external Git repository as a Python module:

    1. Adapt your module so that its compatible with pip install
    1. Your Python module must be hosted on an accessible host, if repository is private, you need to get an access token. For instance, in GitHub, you must generate a personal access token (Other providers may have similar procedures)
    1. Check that downloading of the package works well with your token
    • Zip Archive: https://<access_token>@github.com/<myorg>/<myProject>/archive/<ref>.zip
    • Git: git+https://<access_token>@github.com/<myorg>/<myProject>.git
    • Git with a tag name or commit hash: git+https://<access_token>@github.com/<myorg>/<myProject>.git@<tag>
    • Git with automatic latest release: git+https://<access_token>@github.com/<myorg>/<myProject>.git@latest
    1. Check that pip install works with your URL on your local computer
    pip install <URL>
    1. In your project, in a custom action, add the dependencies in the Advanced Mode in forepaas.json:
    • with a HTTPS Zip archive
          {
            "dependencies": {
              "python": {
                "https://<access_token>@github.com/<myorg>/<myProject>/archive/<ref>.zip": null
              }
            }
          }
    • with a Git+HTTPS repository
          {
            "dependencies": {
              "python": {
                "git+https://<access_token>@github.com/<myorg>/<myProject>.git": null
              }
            }
          }
    • with a Git+HTTPS repository, including a tag name or a commit hash
          {
            "dependencies": {
              "python": {
                "git+https://<access_token>@github.com/<myorg>/<myProject>.git@<tag>": null
              }
            }
          }
    • with a Git+HTTPS repository, automatically using the latest release
          {
            "dependencies": {
              "python": {
                "git+https://<access_token>@github.com/<myorg>/<myProject>.git@latest": null
              }
            }
          }
    Info

    Auto-resolving the latest release: Using @latest at the end of a git+ dependency URL instructs the platform to automatically fetch and substitute the most recent release tag before installing. This removes the need to update each action's dependency manually when a new version of your module is published, click Force Build to pick up the new release. Note that the latest release is not detected automatically at runtime, a manual Force Build is always required.

    Warning

    Pinning a specific tag or commit hash gives you precise control over which version is used at execution time and is recommended for production workloads.

    1. In your custom action python code, you can now import and use it!
    import mypackage

    Go further

    If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.

    Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated Discord channel.

    If you need support with your OVHcloud services, create a request in our Help Centre.

    Join our community of users.