Welcome to PowerOps SDK
What is it?
The PowerOps SDK is a domain-specific SDK for interacting with Cognite Data Fusion (CDF) for the power operations' domain. Requires PowerOps to be deployed and configured for CDF project before using, see project setup instructions for more details.
This SDK is used as a submodule in the power-ops-toolkit repository (private). All toolkit configuration and toolkit deployment workflows are maintained in that repo.
Main Features
cognite.powerops.client.PowerOpsClientused to interact with CDF in a domain-specific language.- Resource Sync,
resync, used to sync configuration files with CDF through the CLI toolpowerops.
Installation
pip install cognite-power-ops
Configuration
Configuration of the PowerOpsClient and resync is done through a yaml file and environment variables.
YAML configuration
The configuration is in .yaml format and the path to the configuration file must be explicitly provided. Refer to the example config file for the most up to date example of required fields.
Secrets should not be written directly in this configuration file as the file is intended to be committed to git. Instead use the following syntax to refer to an environment variable as a value.
project: "${PROJECT}"
base_url: "https://${CLUSTER}.cognitedata.com"
If you are using a .env file etc. then you must handle loading the proper environment variables prior to instantiating PowerOpsClient or running resync.
Usage
Run Resync
Refer to the resync documentation.
PowerOpsClient
Using YAML configuration:
from dotenv import load_dotenv
from cognite.powerops.client import PowerOpsClient
load_dotenv()
power_ops_client = PowerOpsClient.from_config("power_ops_config.yaml")
Using an existing CogniteClient:
from cognite.powerops.client import PowerOpsClient
# Refer to the Cognite SDK documentation for the different ways to instantiate a CogniteClient
cognite_config = {} # dict with configuration
cognite_client = CogniteClient.load(cognite_config)
# Instantiate PowerOpsClient with existing CogniteClient
power_ops_client = PowerOpsClient(client=cognite_client, read_dataset="xid_dataset", write_dataset="xid_dataset")
For more examples on using the PowerOpsClient, see the examples section of the documentation.
Running Tests
Run the test suite with:
pytest
Most tests run against an in-memory mock of PowerOpsClient (tests/mock_powerops.py) and don't require CDF access. Tests that do need a real CDF connection are marked with @pytest.mark.cdf.
To skip the CDF-dependent tests, e.g. when running locally without CDF credentials configured, use the --skipcdf flag. This is also what CI uses:
pytest --skipcdf
Release files for cognite-power-ops 1.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cognite_power_ops-1.1.7.tar.gz | 308.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cognite_power_ops-1.1.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 928.8 kB
Release files / cognite_power_ops-1.1.7.tar.gz
| Download URL | cognite_power_ops-1.1.7.tar.gz |
|---|---|
| Size | 308.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6f348c71527ba71df3272757392685f5d333b4563124446b4f0a8f93a885e333
|
|
BLAKE2b-256 checksum How to use checksums |
c12dcb2b570359d2ba8410d7a4cbef82b2a5fa25038bb56f2d91397ea32f0c11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.21
|
Release files / cognite_power_ops-1.1.7-py3-none-any.whl
| Download URL | cognite_power_ops-1.1.7-py3-none-any.whl |
|---|---|
| Size | 620.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
365b010f80feda9ad84a6608a02aecc3b1bbed48e50691df2a558f3a2c0767d6
|
|
BLAKE2b-256 checksum How to use checksums |
568e755dd2f58b8d27d164c295a6e36485852585db9b86bdc492fb014b37b329
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.21
|