Welcome to Pygen Docs
This is the Cognite Python SDK Generator, pygen
. The purpose of this package is to help developers to
work with Cognite Data Fusion's (CDF) Data Models (DM) in Python.
Beta Note This package, pygen
, is currently in beta, which is reflected in the version number 0.99.x
. Beta
indicates that a product or functionality is in a mature testing phase, but is still subject to change or retirement.
We will provide a deprecation notice a minimum of two months before retiring the product or functionality. We recommend
not using the product or functionality in production systems.
The core functionality is to provide a Python client that matches a data model. This enables the developer for the following benefits
- Client-side validation of the data before writing it to CDF.
- Autocompletion is matching the data model in the integrated developer environment (IDE). This is important as it enables:
- Discoverability of a data model through Python.
- Reduced typing errors in development.
- Keeping the language domain specific for the developer. Instead of working with generic concepts such as instances, nodes and edges, the developer can work with the concepts in the data model.
Documentation
See the documentation for more information.
Installation
Without any optional dependencies
To install this package without CLI support:
With optional dependencies
cli
This includes CLI support such that you can run the package from the command line.
Usage
The goal of the package is to have representations of all the types in a given data model with API calls to .list(), .apply(), .delete(), and .retrieve() individuals for each type.
Creating a Python SDK from a Data Model
Given a Data Model with external id Movie
in the space movies
in CDF, the following command will generate a Python SDK
pygen generate --space movies \
--external-id Movie \
--version 1 \
--tenant-id <tenant-id> \
--client-id <client-id> \
--client-secret <client-secret> \
--cdf-cluster <cdf-cluster> \
--cdf-project <cdf-project>
If you are not using Microsoft Entra ID (Azure AD) you need to specify the parameter --token-url, --scopes and --audience instead of --tenant-id.
Dependencies
Dependencies for the generated SDK
- cognite-sdk This is the basis for all requests to the Cognite Data Fusion API.
- pydantic This is used for all data classes in the generated SDK.
- pandas This is used for
.to_pandas()
methods in the generated SDK.
Dependencies for the pygen
- jinja2 This is used for the templating of the generated SDK.
- inflect This is used for the singularization/pluralization of words in the generated SDK.
- typer (Optional) This is used for the CLI of the
pygen
package. - black (Optional) This is used to format the code generated by the
pygen
package.
Changelog
Wondering about previous changes to the SDK? Take a look at the CHANGELOG.
Contributing
Want to contribute? Check out CONTRIBUTING.