Skip to main content

Malloy Publisher Client

A Python client for interacting with the Malloy Publisher API. This client provides a type-safe interface for working with Malloy projects, packages, models, and executing queries.

Features

  • Type-safe API client with Pydantic models
  • Full support for Malloy Publisher API endpoints
  • Async HTTP client using httpx
  • Comprehensive error handling
  • Context manager support for resource cleanup

Requirements

  • Python 3.11 or higher
  • UV package manager

Installation

You can install the package directly from PyPI:

pip install malloy-publisher-client
# or using uv
uv pip install malloy-publisher-client

For development installation:

  1. Clone the repository:
git clone https://github.com/yourusername/malloy-publisher-client.git
cd malloy-publisher-client
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Unix/macOS
# or
.venv\Scripts\activate  # On Windows
  1. Install dependencies using UV:
uv pip install -e ".[dev]"

Usage

Here's a basic example of how to use the client:

from malloy_publisher_client import MalloyAPIClient, QueryParams

# Initialize the client
client = MalloyAPIClient(
    base_url="https://your-malloy-publisher-url",
    api_key="your-api-key"  # Optional
)

# List all projects
projects = client.list_projects()

# List packages in a project
packages = client.list_packages("project_name")

# List models in a package
models = client.list_models("project_name", "package_name")

# Execute a query
query_params = QueryParams(
    project_name="project_name",
    package_name="package_name",
    path="model_path",
    query="your query here"
)
result = client.execute_query(query_params)

# Use as a context manager
with MalloyAPIClient(base_url="https://your-malloy-publisher-url") as client:
    # Your code here
    pass

Development

Setting Up Development Environment

  1. Install development dependencies:
uv pip install -e ".[dev]"
  1. Install pre-commit hooks (if configured):
pre-commit install

Code Style

This project uses:

  • Black for code formatting
  • MyPy for type checking
  • Ruff for linting

To format code:

black .

To run type checks:

mypy .

To run linter:

ruff check .

Running Tests

The project uses pytest for testing. To run tests:

pytest

For verbose output:

pytest -v

Building and Publishing

To build the package:

# Clean previous builds
rm -rf dist/ build/ *.egg-info/

# Install build tools
uv pip install build twine

# Build the package
python -m build

To publish to PyPI:

  1. Ensure you have a PyPI account and your credentials are configured in ~/.pypirc
  2. Build the package as described above
  3. Upload to PyPI:
python -m twine upload dist/*
  1. Create a git tag for the release:
git tag -a vX.Y.Z -m "Release vX.Y.Z"
git push origin vX.Y.Z

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and ensure all checks pass
  5. Commit your changes using conventional commits
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guide
  • Add type hints to all functions
  • Write docstrings for all public functions and classes
  • Add tests for new functionality
  • Update documentation as needed

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for malloy-publisher-client 0.1.1

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

Source distribution (sdist)

Source distribution for malloy-publisher-client 0.1.1
File Size Uploaded Provenance
malloy_publisher_client-0.1.1.tar.gz 23.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for malloy-publisher-client 0.1.1
File Interpreter ABI Platform
malloy_publisher_client-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / malloy_publisher_client-0.1.1.tar.gz

Download URL malloy_publisher_client-0.1.1.tar.gz
Size 23.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a57d5fb3999b4512e434f729b3ea272aeef5ceda3c51668d1c53a6085fbda8ad
BLAKE2b-256 checksum
How to use checksums
132b7f0f3ffa531e11fa735d6c8cdad7b833f4fe5e008c2d37d57d8d836cb7c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / malloy_publisher_client-0.1.1-py3-none-any.whl

Download URL malloy_publisher_client-0.1.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c178617e7bd20ed8d8197912c2ea4420f6fe7784d0055d5174a9f5d72e4d1d81
BLAKE2b-256 checksum
How to use checksums
e9bb2436d9262dbbad2f4d551d5a4af0b1cdcfbeb36017bb63c0fd4c2342a1ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for malloy-publisher-client 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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

0.1.1 This release

2 release files No 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