Skip to main content

A project manager for Python based extractors

Project description

cogex

cogex is a tool for managing extractors for Cognite Data Fusion written in Python. It provides utilities for initializing a new extractor project and building self-contained executables of Python based extractors.

Important note for users running pyenv

pyenv is a neat tool for managing Python installations.

Since cogex uses PyInstaller to build executables, we need Python to be installed with a shared instance of libpython, which pyenv does not do by default. To fix this, make sure to add the --enable-shared flag when installing new Python versions with pyenv, like so:

env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.9.0

You can read more about it in the PyInstaller documentation

Overview of features

Start a new extractor project

To start a new extractor project, move to the desired directory and run

cogex init

You will first be prompted for some information, before cogex will initialize a new project.

Add dependencies

Extractor projects initiated with cogex will use poetry for managing dependencies. Running cogex init will automatically install the Cognite SDK and extractor-utils framework, but if your extractor needs any other dependency, simply add them using poetry, like so:

poetry add requests

Type checking and code style

It is recommended that you run code checkers on your extractor, in particular:

  • black is an opinionated code style checker that will enforce a consistent code style throughout your project. This is useful to avoid unecessary changes and minimizing PR diffs.
  • isort is a tool that sorts your imports, also contributing to a consistent code style and minimal PR diffs.
  • mypy is a static type checker for Python which ensures that you are not making any type errors in your code that would go unnoticed before suddently breaking your extractor in production.

cogex will install all of these, and automatically run them on every commit. If you for some reason need to perform a commit despite one of these failing, you can run git commit --no-verify, although this is not recommended.

Build and package an extractor project

It is not always an option to rely on a Python installation at the machine your extractor will be deployed at. For those scenarios it is useful to package the extractor, including its dependencies and the Python runtime, into a single self-contained executable. To do this, run

cogex build

This will create a new executable (for the operating system you ran cogex build from) in the dist directory.

Creating a new version of your extractor

To keep track of which version of the code base is running at a given deployment it is very useful to version your extractor. When releasing a new version, run

poetry version [patch/minor/major]

To automatically bump the corresponding version number. Note that this only updates the version number in pyproject.toml. When running cogex build this new version number will be propagated through the rest of the code base.

Any extractor project should follow semantic versioning, which means you should bump

  • patch for any minor bug fixes or improvements
  • minor for new features or bigger improvements that doesn't break compatability
  • major for new feature or improvements that breaks compatability with previous versions, in other words for those scenarios where the new version is not a drop-in replacement for an old version. For example:
    • When adding a new required config field
    • When removing a config field
    • When changing defaults in a way that could break existing deployments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cognite-extractor-manager-0.6.0.tar.gz (15.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cognite_extractor_manager-0.6.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file cognite-extractor-manager-0.6.0.tar.gz.

File metadata

  • Download URL: cognite-extractor-manager-0.6.0.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for cognite-extractor-manager-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f29309c05c2aead04d96b16db0acf3084cd14daf7aedf0a14098360807016d80
MD5 6c793a2887f377812e8a78c2ae7387d1
BLAKE2b-256 8cd1d5678363e9f4a2721a591b82eeb04d7eff961a9d756654f96e8e044e5e01

See more details on using hashes here.

File details

Details for the file cognite_extractor_manager-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: cognite_extractor_manager-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/35.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for cognite_extractor_manager-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0fba7506c879ed8142c1977e28a2862cabac41460d034b98bfff15ce1c1677d
MD5 8b17c2ca50c934c38686d925038abade
BLAKE2b-256 46817f9fb2997ad02956cc01e86759383c101fedfe791e5d18a4e4f52552a83e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page