Skip to main content

Acceleration libraries for CosmoTech cloud based solution development

Project description

CosmoTech-Acceleration-Library (CoAL)

Acceleration library for CosmoTech cloud-based solution development.

Introduction

The CosmoTech Acceleration Library (CoAL) provides a comprehensive set of tools and utilities to accelerate the development of solutions based on the CosmoTech platform. It offers a unified interface for interacting with CosmoTech APIs, managing data, and integrating with various cloud services.

Main Components

csm-data

csm-data is a powerful CLI tool designed to help CosmoTech solution modelers and integrators interact with multiple systems. It provides ready-to-use commands to send and retrieve data from various systems where a CosmoTech API could be integrated.

# Get help on available commands
csm-data --help

# Get help on specific command groups
csm-data api --help

datastore

The datastore provides a way to maintain local data during simulations and comes with csm-data commands to easily send those data to target systems. It offers:

  • Format flexibility (Python dictionaries, CSV files, Pandas DataFrames, PyArrow Tables)
  • Persistent storage in SQLite
  • SQL query capabilities
  • Simplified data pipeline management
from cosmotech.coal.store.store import Store
from cosmotech.coal.store.native_python import store_pylist

# Initialize and reset the data store
my_datastore = Store(reset=True)

# Create and store data
my_data = [{"foo": "bar"}, {"foo": "barbar"}, {"foo": "world"}, {"foo": "bar"}]
store_pylist("my_data", my_data)

# Query the data
results = my_datastore.execute_query("SELECT foo, count(*) as line_count FROM my_data GROUP BY foo").to_pylist()
print(results)
# > [{'foo': 'bar', 'line_count': 2}, {'foo': 'barbar', 'line_count': 1}, {'foo': 'world', 'line_count': 1}]

CosmoTech API Integration

CoAL provides comprehensive tools for interacting with the CosmoTech API, allowing you to:

  • Authenticate with different identity providers (API Key, Azure Entra, Keycloak)
  • Manage workspaces and files
  • Work with the Twin Data Layer for graph data
  • Handle runners and runs
  • Process and transform data
  • Build end-to-end workflows
import os
from cosmotech.coal.cosmotech_api.connection import get_api_client

# Set up environment variables for authentication
os.environ["CSM_API_URL"] = "https://api.cosmotech.com"  # Replace with your API URL
os.environ["CSM_API_KEY"] = "your-api-key"  # Replace with your actual API key

# Get the API client
api_client, connection_type = get_api_client()
print(f"Connected using: {connection_type}")

# Use the client with various API instances
from cosmotech_api.api.organization_api import OrganizationApi
org_api = OrganizationApi(api_client)

# List organizations
organizations = org_api.find_all_organizations()
for org in organizations:
    print(f"Organization: {org.name} (ID: {org.id})")

# Don't forget to close the client when done
api_client.close()

Other Components

  • coal: Core library with modules for API interaction, data management, etc.
  • csm_data: CLI tool for data management and integration with various systems
  • orchestrator_plugins: Plugins that integrate with external orchestration systems
  • translation: Internationalization support for multiple languages

Getting Started

Installation

pip install cosmotech-acceleration-library

Basic Usage

Check out the tutorials directory for comprehensive examples of how to use the library:

Key Features

Cloud Service Integration

CoAL provides built-in support for various cloud services:

  • Azure: Azure Data Explorer (ADX), Azure Storage, Azure Functions
  • AWS: S3 buckets, and more
  • Database Systems: PostgreSQL, SingleStore, and others

Data Management

  • Load and transform data from various sources
  • Store and query data locally
  • Export data to different formats and destinations
  • Manage datasets in the CosmoTech platform

Orchestration Integration

  • Provides plugins that integrate with external orchestration systems
  • Supports data transfer between orchestration steps
  • Offers utilities for handling parameters and configurations
  • Enables seamless integration with the CosmoTech platform during orchestrated workflows

Documentation and Tutorials

Comprehensive documentation is available at https://cosmo-tech.github.io/CosmoTech-Acceleration-Library/

Tutorials

  • CosmoTech API: Learn how to interact with the CosmoTech API directly: authentication, workspaces, Twin Data Layer, and more.
  • Data Store: The datastore is your friend to keep data between orchestration steps. It comes with multiple ways to interact with it.
  • csm-data: Make full use of csm-data commands to connect to services during your orchestration runs.

Testing and Code Coverage

The CosmoTech Acceleration Library maintains a comprehensive test suite to ensure reliability and stability. We use pytest for testing and pytest-cov for coverage reporting.

Running Tests

To run the test suite:

# Install test dependencies
pip install -e ".[test]"

# Run tests with coverage reporting
pytest tests/unit/coal/ --cov=cosmotech.coal --cov-report=term-missing --cov-report=html

Coverage Reports

After running tests with coverage, you can view detailed HTML reports:

# Open the HTML coverage report
open coverage_html_report/index.html

codecov

We maintain high test coverage to ensure code quality and reliability. All pull requests are expected to maintain or improve the current coverage levels.

Test Generation Tools

To help maintain test coverage, we provide tools to identify untested functions and generate test files:

# Find functions without tests
python find_untested_functions.py

# Generate test files for a specific module
python generate_test_files.py --module cosmotech/coal/module/file.py

# Generate test files for all untested functions
python generate_test_files.py --all

These tools help ensure that every function has at least one test, which is a requirement for contributions to the project.

Contact

For support, feature requests, or contributions, please use the GitHub repository.

Project details


Release history Release notifications | RSS feed

This version

2.2.0

Download files

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

Source Distribution

cosmotech_acceleration_library-2.2.0.tar.gz (62.4 kB view details)

Uploaded Source

Built Distribution

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

cosmotech_acceleration_library-2.2.0-py3-none-any.whl (128.6 kB view details)

Uploaded Python 3

File details

Details for the file cosmotech_acceleration_library-2.2.0.tar.gz.

File metadata

File hashes

Hashes for cosmotech_acceleration_library-2.2.0.tar.gz
Algorithm Hash digest
SHA256 31649d25d8540d817163aa01142bbcff6a0e7e3b0ef6dc99a54193e9e2edaf4d
MD5 50eeac9e00a074a2c10bdff03de07300
BLAKE2b-256 6af18c12aa1ce613696167cfc5c5bb5cb3c10c2eebc64029ef6dae8e6a50ae70

See more details on using hashes here.

File details

Details for the file cosmotech_acceleration_library-2.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cosmotech_acceleration_library-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df70f7214cc1f5b90132cd91f2b3d3ae5b1a5d48de255ff768cddeda2080af79
MD5 63a49273910d0c031f1c1f85b88d60c4
BLAKE2b-256 1fdb8bca7cee317e364d458b3eb53a83c5d9026dc533537d2e0207c3acacd3a0

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