Skip to main content

The Python library for Archimedes

Project description

archimedes-python-client

archimedes is the python sdk for accessing Optimeering data. This document outlines the setup of environment, authentication and general usage of the python client to fetch RK within day data using python.

Setting up the environment

We will be using venv to manage the virtual environment in this example.

Creating a virtual environment.

python3 -m venv .venv

This will create a directory named .venv where all the dependencies will be installed.

Activating the virtual environment

source ./.venv/bin/activate # linux/macOS
.venv\Scripts\activate.bat # Windows cmd
.\.venv\Scripts\Activate.ps1 # Windows PowerShell

Installingarchimedes-python-client

python3 -m pip install archimedes-python-client

Authentication

For local development:

For local development, the python client can use user authentication. The users are can be authenticated using the archimedes command line tool arcl.

python3 -m pip install arcl

arcl auth login # then, follow the instructions to login with your Microsoft account

Once the user is logged in, the archimedes login information will be stored in your ~/.archimedes directory and all the scripts and applications running as the same user are able to authenticate to the API automatically when using the archimedes-python-client.

For deployed applications:

The python client uses the following fields in environment variable for authentication of the client.

  1. AZURE_AD_TENANT_ID Provided by Optimeering AS
  2. AZURE_AD_APP_ID Provided by Optimeering AS
  3. AZURE_AD_APP_CLIENT_CREDENTIAL Provided by Optimeering AS
  4. USE_APP_AUTHENTICATION Set to True

As long as these variables have been set up as environment variables, any python script that invokes methods in archimedes will automatically use the values in the environment variables for authentication.

Example Code

Below is a code sample that invokes an archimedes method.

#import os
import archimedes

# The following environment variables are only needed for deployed applications.
# These would ideally be set in the app runtime environment and not necessarily in 
# python code
# os.environ["AZURE_AD_TENANT_ID"] = "***azure_ad_tenant_id***"
# os.environ["AZURE_AD_APP_ID"] = "***azure_ad_client_id***"
# os.environ["AZURE_AD_APP_CLIENT_CREDENTIAL"] = "***secret***"
# os.environ["USE_APP_AUTHENTICATION"] = "true"

data = archimedes.rk_within_day.directions(
    start="2023-01-01 00:00:00+0000",
    price_area="NO1",
    end="2023-01-01 01:00:00+0000",
    ref_dt="2022-12-31 23:00:00+0000"
)
print(data)

The sample code prints the RK within day directions probability for provided constraints to the console.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

archimedes_python_client-4.18.11.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

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

archimedes_python_client-4.18.11-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file archimedes_python_client-4.18.11.tar.gz.

File metadata

  • Download URL: archimedes_python_client-4.18.11.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.10.13 Linux/6.2.0-1011-azure

File hashes

Hashes for archimedes_python_client-4.18.11.tar.gz
Algorithm Hash digest
SHA256 11c9d4351a70d765eddc35826a723ade07aa9ac4cb058800fd8bb7bbd44ad1d5
MD5 742f7bdfe6279b6f1c904c0aa59e794c
BLAKE2b-256 552ba8eecef63405643339252a003446260479b1b3aa21cca816adef2525837a

See more details on using hashes here.

File details

Details for the file archimedes_python_client-4.18.11-py3-none-any.whl.

File metadata

File hashes

Hashes for archimedes_python_client-4.18.11-py3-none-any.whl
Algorithm Hash digest
SHA256 7f53acf124fbb334800105a200e0b0bd4d914a2961881e9019ccf656316fe584
MD5 8440f444d519fbc66c4f6f2ff5b6161b
BLAKE2b-256 9d73e24f82e7cfa9aa659b8c4b8303cfc35bcd568ec720a2bb1935ed0a8122ba

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