A Python client for the Malloy Publisher API
Project description
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:
- Clone the repository:
git clone https://github.com/yourusername/malloy-publisher-client.git
cd malloy-publisher-client
- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
- 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
- Install development dependencies:
uv pip install -e ".[dev]"
- 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:
- Ensure you have a PyPI account and your credentials are configured in
~/.pypirc - Build the package as described above
- Upload to PyPI:
python -m twine upload dist/*
- 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
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and ensure all checks pass
- Commit your changes using conventional commits
- Push to the branch (
git push origin feature/amazing-feature) - 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file malloy_publisher_client-0.1.1.tar.gz.
File metadata
- Download URL: malloy_publisher_client-0.1.1.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a57d5fb3999b4512e434f729b3ea272aeef5ceda3c51668d1c53a6085fbda8ad
|
|
| MD5 |
806c93b0c6c81a79baf8ebad5e1356ce
|
|
| BLAKE2b-256 |
132b7f0f3ffa531e11fa735d6c8cdad7b833f4fe5e008c2d37d57d8d836cb7c5
|
File details
Details for the file malloy_publisher_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: malloy_publisher_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c178617e7bd20ed8d8197912c2ea4420f6fe7784d0055d5174a9f5d72e4d1d81
|
|
| MD5 |
b02d21ab35044a8ba7ee6328ce4d22b2
|
|
| BLAKE2b-256 |
e9bb2436d9262dbbad2f4d551d5a4af0b1cdcfbeb36017bb63c0fd4c2342a1ce
|