Skip to main content

License

PyPI - Version PyPI - Python Version

Modular SDK

You use Modular SDK to create, configure, and manage common entities, such as:

  • Customers;
  • Tenants;
  • TenantSettings;
  • Regions;
  • Applications;
  • Parents;

Prerequisites

  • Python 3.14 required

Building distribution archives

  • Make sure you have the latest version of PyPA’s build installed: python3 -m pip install --upgrade build
  • Run the command form the same directory where pyptoject.toml is located: python3 -m build
  • This command should output a lot of text and once completed should generate two files in the dist directory:
dist/
    modular_sdk-{version}.tar.gz
    modular_sdk-{version}-py3-none-any.whl

Installation

  • pip install modular-sdk

Usage

To use Modular SDK, you must import, configure and indicate which service or services you're going to use:

from modular_sdk.modular import Modular

modular_sdk = Modular()

parent_service = modular_sdk.parent_service()
tenant_service = modular_sdk.tenant_service()

For services that aren't tied to the service_mode configuration, you can use ModularServiceProvider:

from modular_sdk.modular import ModularServiceProvider

modular_sdk = ModularServiceProvider()

thread_local_storage_service = modular_sdk.thread_local_storage_service()

For now, Modular provides 3 ways of DB access. Depends on the way of database connection, different sets of env variables must be set:

  1. Onprem, Mongodb:
    modular_service_mode: docker,
    modular_mongo_user: $MONGO_USER,
    modular_mongo_password: $MONGO_PASSWORD,
    modular_mongo_url: $MONGO_URL,
    modular_mongo_db_name: $MONGO_DB_NAME,
    modular_mongo_srv: True, # Optional
    Alternatively, instead of specifying modular_mongo_user, modular_mongo_password,
    modular_mongo_url, and modular_mongo_srv, you can use:
    modular_mongo_uri: $MONGO_URI # Format: mongodb+srv://<USER>:<PASSWORD>@<URL>/
  2. SaaS, DynamoDB (cross-account access):
    modular_service_mode: saas # Optional
    modular_assume_role_arn: $ASSUME_ROLE_ARN
  3. SAAS, DynamoDB (same AWS account):
    modular_service_mode: saas # Optional

Alternatively, you can pass these parameters (fully or partially) on initialization:

from modular_sdk.modular import Modular

modular_sdk = Modular(modular_service_mode='docker',
                      modular_mongo_user='MONGO_USER',
                      modular_mongo_password='MONGO_PASSWORD',
                      modular_mongo_url='MONGO_URL',
                      modular_mongo_db_name='DB_NAME')

# initialize some services
application_service = modular_sdk.application_service()
parent_service = modular_sdk.parent_service()

More examples

Example 1: List Maestro Customers

from modular_sdk.modular import Modular

# initializing application service
customer_service = Modular().customer_service()

# listing available customers 
customers = customer_service.list()

# printing customer names
for customer in customers:
   print(customer.name)

Example 2: Update Maestro Application

from modular_sdk.modular import Modular

# initializing application service
application_service = Modular().application_service()

# extracting application by id
application = application_service.get_application_by_id(
   application_id="$APP_ID")

# updating application description
description_to_set = 'Updated application description'
application_service.update(application=application,
                           description=description_to_set)

# saving updated application
application_service.save(application=application)

Example 3: Delete Maestro Parent

from modular_sdk.modular import Modular

# initializing parent service
parent_service = Modular().parent_service()

# extracting parent by id
parent = parent_service.get_parent_by_id(parent_id="$PARENT_ID")

# deleting parent
parent_service.mark_deleted(parent=parent)

Transactions

Repositories can accept an optional transaction session and use it for all database writes:

from modular_sdk.models.pynamongo import TransactionAdapter

# The backend is selected from the model configuration.
adapter = TransactionAdapter(model=Quota)

with adapter.transaction() as session:
    quota_repository.reserve(quota_id, session=session)
    job_repository.create(job, session=session)

Inside a repository, write through the session when one is provided:

# job_repository.py

def create(self, job, session=None):
    if session is None:
        return job.save()
    return session.save(job)

Always pass the session to every write that belongs to the transaction. Calling job.save() directly inside the with block bypasses the transaction.

The DynamoDB transaction is committed when the context exits successfully and is rolled back when an exception is raised. DynamoDB transactions support up to 100 actions, allow only one action per item, and all items must be in the same region. An empty DynamoDB transaction fails on commit.

MongoDB transactions require a replica set or sharded cluster. MongoDB allows multiple writes to the same document, and an empty MongoDB transaction commits successfully.

Metadata

Release files for modular-sdk 8.2.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 modular-sdk 8.2.0
File Size Uploaded Provenance Actions
modular_sdk-8.2.0.tar.gz 83.3 kB With provenance Details for modular_sdk-8.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for modular-sdk 8.2.0
File Interpreter ABI Platform Actions
modular_sdk-8.2.0-py3-none-any.whl Python 3 none any Details for modular_sdk-8.2.0-py3-none-any.whl

Total release size: 188.4 kB

Release files / modular_sdk-8.2.0.tar.gz

Download URL modular_sdk-8.2.0.tar.gz
Size 83.3 kB
Tags Source
SHA-256 checksum
How to use checksums
eb229ccdbc8abbcfd346346aa84ad3ba2d99c5166b5fde7a8ddbd617f0219915
BLAKE2b-256 checksum
How to use checksums
02e885e892b7bfbe6c624e1230d09c2de6b23f20d86ee06abc9a0083ba12a16d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / modular_sdk-8.2.0-py3-none-any.whl

Download URL modular_sdk-8.2.0-py3-none-any.whl
Size 105.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d77c38333dc9a193f405ef98c8012cf1f21a5b37b17ba88ae1123153ea49104c
BLAKE2b-256 checksum
How to use checksums
787c42bbdddcf39fd8a4b42f0b32cadb89b394e5f0165a0712f0c57eff3be8bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for modular-sdk 8.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for modular_sdk-8.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

8.2.0 This release

2 release files Full provenance

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