Skip to content

atlanhq/atlan-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

pyatlan Logo

The official Python SDK for the Atlan πŸ’™

PyPI version Python versions License Downloads Build Status Documentation Docker


πŸ“– Documentation β€’ 🐳 Docker β€’ 🀝 Contributing

-----------------------------------------------------

πŸ“Š Project Stats

  • 🐍 Python Versions: 3.9, 3.10, 3.11, 3.12, 3.13
  • πŸ“¦ Package Size: Optimized for fast installation
  • πŸš€ Performance: Built with modern async/await support
  • πŸ”§ Dependencies: Minimal, modern stack
  • πŸ“ˆ Stability: Production-ready

πŸ“¦ Installation

Production Use

# Latest stable version
pip install pyatlan

# Specific version
pip install pyatlan==7.1.3

# With uv (faster) - install uv first: curl -LsSf https://astral.sh/uv/install.sh | sh
uv add pyatlan

Development Setup

# Clone the repository
git clone https://github.com/atlanhq/atlan-python.git
cd atlan-python

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install with development dependencies
uv sync --group dev

# Run quality checks
uv run ./qa-checks

# Run tests
uv run pytest tests/unit

Dependency Groups

This project uses uv dependency groups for better dependency management:

  • Core dependencies: Always installed (uv sync)
  • Development dependencies: Testing, linting, formatting (uv sync --group dev)
  • Documentation dependencies: Sphinx docs (uv sync --group docs)

You can install multiple groups:

# Install both dev and docs dependencies
uv sync --group dev --group docs

# Install all dependencies
uv sync --all-groups

🐳 Docker

Pre-built Images

# Latest version
docker pull ghcr.io/atlanhq/atlan-python:latest

# Specific version
docker pull ghcr.io/atlanhq/atlan-python:7.1.3

Usage

# Interactive Python session
docker run -it --rm ghcr.io/atlanhq/atlan-python:latest

# Run a script
docker run -it --rm \
  -v $(pwd):/app \
  -e ATLAN_API_KEY=your_key \
  -e ATLAN_BASE_URL=https://your-tenant.atlan.com \
  ghcr.io/atlanhq/atlan-python:latest \
  python your_script.py

πŸ§ͺ Testing

Unit Tests

# Run all unit tests
uv run pytest tests/unit

# Run with coverage
uv run pytest tests/unit --cov=pyatlan --cov-report=html

Integration Tests

# Set up environment
cp .env.example .env
# Edit .env with your Atlan credentials

# Run integration tests
uv run pytest tests/integration

Quality Assurance

# Run all QA checks (formatting, linting, type checking)
uv run ./qa-checks

# Individual checks
uv run ruff format .          # Code formatting
uv run ruff check .           # Linting
uv run mypy .                 # Type checking

🀝 Contributing

We welcome contributions! Here's how to get started:

Development Setup

# Fork and clone the repository
git clone https://github.com/your-username/atlan-python.git
cd atlan-python

# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install development dependencies
uv sync --group dev

# Install pre-commit hooks
uv run pre-commit install

Making Changes

# Create a feature branch
git checkout -b feature/amazing-feature

# Make your changes and test
uv run ./formatter
uv run ./qa-checks
uv run pytest tests/unit

# Commit with conventional commits
git commit -m "feat: add amazing feature"

# Push and create a pull request
git push origin feature/amazing-feature

Guidelines

  • βœ… Follow conventional commits
  • βœ… Add tests for new features
  • βœ… Update documentation as needed
  • βœ… Ensure all QA checks pass

πŸ› οΈ SDK Generator

Generate asset models from your Atlan instance:

# Generate models automatically
uv run ./generator

# Use custom typedefs file
uv run ./generator ./my-typedefs.json

This will:

  • πŸ“₯ Retrieve typedefs from your Atlan instance
  • πŸ—οΈ Generate asset models, enums, and structures
  • 🎨 Format code automatically
  • ⚑ Support incremental updates

πŸ“ Project Structure

Understanding the codebase layout will help you navigate and contribute effectively:

atlan-python/
β”œβ”€β”€ pyatlan/                          # 🐍 Main Python package
β”‚   β”œβ”€β”€ __init__.py                   # Package initialization
β”‚   β”œβ”€β”€ cache/                        # πŸ’Ύ Caching mechanisms
β”‚   β”‚   β”œβ”€β”€ atlan_tag_cache.py       # Tag name ↔ GUID mapping
β”‚   β”‚   β”œβ”€β”€ custom_metadata_cache.py  # Custom metadata definitions
β”‚   β”‚   β”œβ”€β”€ enum_cache.py            # Enum value caching
β”‚   β”‚   └── aio/                     # Async versions of caches
β”‚   β”œβ”€β”€ client/                       # 🌐 HTTP client implementations
β”‚   β”‚   β”œβ”€β”€ atlan.py                 # Main synchronous client
β”‚   β”‚   β”œβ”€β”€ asset.py                 # Asset operations (CRUD, search)
β”‚   β”‚   β”œβ”€β”€ admin.py                 # Administrative operations
β”‚   β”‚   β”œβ”€β”€ audit.py                 # Audit log operations
β”‚   β”‚   β”œβ”€β”€ common/                  # Shared client logic
β”‚   β”‚   └── aio/                     # Async client implementations
β”‚   β”œβ”€β”€ model/                        # πŸ“Š Data models and assets
β”‚   β”‚   β”œβ”€β”€ assets/                  # Asset type definitions
β”‚   β”‚   β”‚   β”œβ”€β”€ core/                # Core asset types (Table, Database, etc.)
β”‚   β”‚   β”‚   └── relations/           # Relationship models
β”‚   β”‚   β”œβ”€β”€ fields/                  # Search field definitions
β”‚   β”‚   β”œβ”€β”€ open_lineage/            # OpenLineage specification models
β”‚   β”‚   β”œβ”€β”€ packages/                # Package/workflow models
β”‚   β”‚   └── aio/                     # Async model variants
β”‚   β”œβ”€β”€ generator/                    # πŸ—οΈ Code generation tools
β”‚   β”‚   β”œβ”€β”€ templates/               # Jinja2 templates for generation
β”‚   β”‚   └── class_generator.py       # Main generation logic
β”‚   β”œβ”€β”€ pkg/                         # πŸ“¦ Package creation utilities
β”‚   β”œβ”€β”€ events/                      # πŸ”” Event handling (webhooks, lambdas)
β”‚   β”œβ”€β”€ samples/                     # πŸ’‘ Example code and scripts
β”‚   └── test_utils/                  # πŸ§ͺ Testing utilities
β”œβ”€β”€ tests/                            # πŸ§ͺ Test suite
β”‚   β”œβ”€β”€ unit/                        # Unit tests (fast, no external deps)
β”‚   β”œβ”€β”€ integration/                 # Integration tests (require Atlan instance)
β”‚   └── data/                        # Test fixtures and mock data
β”œβ”€β”€ docs/                            # πŸ“š Sphinx documentation
β”‚   β”œβ”€β”€ conf.py                      # Sphinx configuration
β”‚   └── *.rst                       # Documentation source files
β”œβ”€β”€ pyproject.toml                   # πŸ“‹ Project configuration (deps, tools)
β”œβ”€β”€ uv.lock                          # πŸ”’ Locked dependencies
β”œβ”€β”€ qa-checks                        # βœ… Quality assurance script
β”œβ”€β”€ formatter                        # 🎨 Code formatting script
└── generator                        # πŸ—οΈ Model generation script

Key Components

🌐 Client Layer (pyatlan/client/)

  • Synchronous: Direct HTTP operations using httpx
  • Asynchronous: Async/await operations using httpx.AsyncClient
  • Common: Shared business logic between sync/async clients
  • Specialized: Domain-specific clients (admin, audit, lineage, etc.)

πŸ“Š Model Layer (pyatlan/model/)

  • Assets: 400+ asset types (tables, dashboards, pipelines, etc.)
  • Core Models: Base classes, requests, responses
  • Fields: Search and filtering field definitions
  • OpenLineage: Data lineage specification compliance

πŸ’Ύ Cache Layer (pyatlan/cache/)

  • Tag Cache: Maps human-readable tag names to internal GUIDs
  • Custom Metadata: Caches custom attribute definitions
  • Connection Cache: Stores connector and connection metadata
  • Async Variants: Full async implementations for all caches

πŸ—οΈ Generation System (pyatlan/generator/)

  • Templates: Jinja2 templates for assets, enums, documentation
  • Generator: Retrieves typedefs and generates Python models
  • Incremental: Only regenerates changed models for efficiency

πŸ§ͺ Testing Strategy

  • Unit Tests: Fast, isolated tests with mocks/fixtures
  • Integration Tests: Real API calls (requires credentials)
  • VCR Cassettes: Record/replay HTTP interactions for consistent testing

πŸ“¦ Package System (pyatlan/pkg/)

  • Custom Packages: Framework for building Atlan-deployable packages
  • Templates: Pre-built package structures and configurations
  • Utilities: Helper functions for package development

Development Workflow

  1. Models: Generated from your Atlan instance's typedefs
  2. Clients: Hand-crafted for optimal developer experience
  3. Tests: Mix of unit (fast iteration) and integration (real validation)
  4. Quality: Automated formatting, linting, and type checking
  5. Documentation: Auto-generated from docstrings and examples

πŸ“„ License

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

πŸ™ Attribution

Portions of this SDK are based on original work from:

Built with πŸ’™ by Atlan

Website β€’ Documentation β€’ Support

-----------------------------------------------------