Skip to main content
DHI

MIKE Cloud Platform SDK for Python

What is MIKE Cloud Platform SDK for Python?

MIKE Cloud Platform SDK for Python allows you to programmatically access MIKE Cloud Platform from Python. It also includes set of CLI tools to manipulate data and access services in MIKE Cloud Platform.

Here is a small example:

plt cfg login --login
plt prj create --name "My project"
plt prj ls

See the documentation for more examples.

MIKE Cloud Platform SDK for Python is in development; some features are missing and there could be even bugs :-o

Requirements

You need Python 3.8 or later. In Ubuntu, Mint and Debian you can install Python 3 like this:

$ sudo apt-get install python3 python3-pip python3-wheel python3-cffi python3-cryptography python3-greenlet python3-gevent python3-yaml

In Alpine:

$ apk add --no-cache bash python3 py3-pip py3-wheel py3-cffi py3-cryptography py3-greenlet py3-gevent py3-yaml

For other Linux flavors, macOS and Windows, packages are available at

https://www.python.org/getit/

Quick start

MIKE Cloud Platform SDK for Python and additional packages are installed using pip:

$ pip install -U dhi-platform

If you want to run the latest stable version of the code, you can install from git:

$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAML
$ pip install -U git+https://dhigroup@dev.azure.com/dhigroup/MIKE/_git/mike-platform-sdk-py@master

Or if you want to run the latest development (unstable) version of the code from git:

$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAML
$ pip install -U git+https://dhigroup@dev.azure.com/dhigroup/MIKE/_git/mike-platform-sdk-py@develop

Manual installation: get files from mike-platform-sdk-py repository (https://dhigroup@dev.azure.com/dhigroup/MIKE/_git/mike-platform-sdk-py). Add "src" directory to PYTHONPATH and "bin" directory to PATH. Install additional packages: azure-identity, azure-storage-blob, signalrcore, signalr-async and PyYAML:

$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAML

How to authenticate in Python

When creating MIKE Cloud Platform clients in Python, you must provide credentials. There are three ways to do that:

  1. Device code flow

This is the recommended way to authenticate when using the Python SDK. You need to register your device with the Platform IAM system (contact wdpservice@dhigroup.com) Note that with device code flow, all requests will be performed on behalf of the device, not on behald of the user who set the device up.

Example:

from dhi.platform.authentication import DeviceCodeDhiIdentity
from dhi.platform.metadata import MetadataClient

client_id = "<my client id>"
client_secret = "<my client secret>
identity = DeviceCodeDhiIdentity(client_id, client_secret environment="dev", forcelogin=True)
metadata_client = MetadataClient(identity=identity)
  1. Using open api key

We recommend using the device code flow option above. However, open api key is still an available option. When using api, all requests will be performed on behalf of the creator of the open api account.

Provided you have a valid api key and the corresponding open api key account has been assigned to a project, you can create an identity and provide that to clients. Open API key for the MIKE Cloud Platform can be requested through your DHI Cloud Platform Account Administrator (i.e. for DHI through mike@dhigroup.com) and assigned to projects using Data Admin UI application.

Example:

from dhi.platform.authentication import ApiKeyIdentity
from dhi.platform.metadata import MetadataClient
customer_id = "<customer id>"
key = "<api key uuid>"
identity = ApiKeyIdentity(customer_id=customer_id, apikey=key)
client = MetadataClient(identity=identity)
  1. Using interactive user login

When using interactive user login, all requests would be performed on behalf of the logged in user This option is not implement out of the box. It requires a server component running on the client side. The server component must be able to handle authentication callback HTTP request from the the DHI MIKE Cloud Platform IAM. This option would be suitable for example when using this python package from a Python web application backed. Contact wdpservice@dhigroup.com if you need more information.

If you want to target a different environment than production, provide the optional environment parameter.

Web site and documentation

Documentation and additional information is available at the web site:

https://develop.mike-cloud.com

Or you can jump straight to the documentation:

https://develop.mike-cloud.com/docs/

Troubleshooting

Depending on your configuration, you may have to run pip like this:

$ pip install --no-deps -U dhi-platform

This doesn't automatically install the appropriate version of azure-identity, azure-storage-blob, signalrcore, signalr-async and PyYAML. You can install them manually:

$ pip install -U azure-identity azure-storage-blob signalrcore signalr-async PyYAML

If the plt command isn't found after installation: After pip install, the plt script and dependencies, will be installed to system-dependent locations. Sometimes the script directory will not be in PATH, and you have to add the target directory to PATH manually or create a symbolic link to the script. In particular, on macOS, the script may be installed under /Library/Frameworks:

/Library/Frameworks/Python.framework/Versions/<version>/bin

In Windows, the script is generally installed in \PythonNN\Scripts. So, type check a program like this (replace \Python38 with your Python installation path):

C:\>\Python38\python \Python38\Scripts\plt ...

Working with virtualenv

If you are using virtualenv, make sure you are running a python3 environment. Installing via pip3 in a v2 environment will not configure the environment to run installed modules from the command line.

$ pip install -U virtualenv
$ python3 -m virtualenv env

Development status

MIKE Cloud Platform SDK for Python is beta software.

Changelog

Issue tracker

License

MIKE Cloud Platform SDK for Python is licensed under the terms of the MIT License (see the file LICENSE).

Release files for dhi-platform 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dhi-platform 1.1.0
File Size Uploaded
dhi_platform-1.1.0.tar.gz 262.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dhi-platform 1.1.0
File Interpreter ABI Platform
dhi_platform-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 605.7 kB

Release files / dhi_platform-1.1.0.tar.gz

Download URL dhi_platform-1.1.0.tar.gz
Size 262.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9b86a7fc47b6ec9bb833398d15391268846cec73e0d7f8c3da1ef2c6d4e05db0
BLAKE2b-256 checksum
How to use checksums
a6add62e5c886dd7a4560b318f35dc6f778edd2c8137eee3442c88a74c741eb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release files / dhi_platform-1.1.0-py3-none-any.whl

Download URL dhi_platform-1.1.0-py3-none-any.whl
Size 343.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0459d899bd7770933006ebbac55b08ea54297e4fdd562990acd098b9b58cc557
BLAKE2b-256 checksum
How to use checksums
8121762d127a0723d71c728fb3524bfe2cd2ceb059a7a9bcb6d7d83518573bb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.18

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.10

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page