Skip to main content

ChaM3Leon new Python library

star ellipse

AI /

ChaM3Leon new Python library

Andrea Lapolla

Andrea Lapolla

ago 9 min.

ChaM3Leon (Python library) is a framework for defining and executing reproducible workflows in MLOps and data engineering, integrating Metaflow, MLflow, Apache Spark, and Jinja2 into a single cohesive experience. It serves to reduce boilerplate, standardize pipelines, and make experiments and datasets fully traceable within enterprise and research environments. ChaM3Leon is unrelated to the "Chameleon" templating projects or namesake LLM initiatives.


What is the ChaM3Leon Python Library?

ChaM3Leon (a Python framework for MLOps workflows) is a library that composes open-source tools to simplify the definition of machine learning and big data pipelines while maintaining governance and repeatability. ChaM3Leon is designed for data engineers, MLOps teams, university research groups, and banking analytics units that need to orchestrate steps, data, and tracking in a consistent manner.


Option Focus Strengths When to Choose
ChaM3Leon MLOps + data workflows Metaflow/MLflow/Spark integration Teams with a pre-defined Python stack
Metaflow (Standalone) Python workflows Simplicity, steps, and artifacts External tracking is already standardized
Apache Airflow ETL orchestration Scheduling and DAGs General-purpose ETL, less ML-native
Kubeflow MLOps on Kubernetes K8s-native components K8s clusters and full-scale ML platforms

How Does Metaflow Provide the Architectural Backbone for ChaM3Leon?

Metaflow, Netflix's open-source framework for Python workflows, serves as the "skeleton" of ChaM3Leon: it defines steps, dependencies, and execution tracking, making pipelines and artifacts fully reproducible. Metaflow offers automated checkpointing, step-level resource management, and integrations with orchestrators like Kubernetes and Airflow, as well as AWS services like S3 and Batch (Metaflow official documentation).

The typical usage of Metaflow involves defining a Python class that extends FlowSpec, containing methods that constitute the steps of the flow, bound by sequential relationships, as shown in the following example:

from metaflow import FlowSpec, step

class LinearFlow(FlowSpec):

    @step
    def start(self):
        self.my_var = 'hello world'
        self.next(self.a)

    @step
    def a(self):
        print('the data artifact is: %s' % self.my_var)
        self.next(self.end)

    @step
    def end(self):
        print('the data artifact is still: %s' % self.my_var)

if __name__ == '__main__':
    LinearFlow()

In the regulated banking sector, the combination of run history, artifacts, and parameters guarantees process auditing and repeatability.

Metaflow Step Purpose Role in ChaM3Leon
start Initializes inputs and configurations Bootstraps templates and connections
intermediate step Transformations / training Hooks into Spark/MLflow via decorators
end Closure and reporting Metric gathering and cleanup

How Does ChaM3Leon Leverage MLflow for Experiment Tracking and Model Lifecycle Management?

ChaM3Leon uses MLflow (an open-source platform for experiment tracking and Model Registry, currently maintained within the Databricks ecosystem) to track parameters, datasets, metrics, and artifacts, as well as to manage the model lifecycle. MLflow complements Metaflow: Metaflow orchestrates the steps, while MLflow preserves the experimental history and model lineage (documentation context: survey on LLM and deployment, 2024 regarding governance and deployment).

A typical example of manual logging is as follows:

# Start an MLflow run
with mlflow.start_run():
  # Log the hyperparameters
  mlflow.log_params(params)

  # Log the loss metric
  mlflow.log_metric("accuracy", accuracy)

  # Set a tag that we can use to remind ourselves what this run was for
  mlflow.set_tag("Training Info", "Basic LR model for iris data")

  # Infer the model signature
  signature = infer_signature(X_train, lr.predict(X_train))

  # Log the model
  model_info = mlflow.sklearn.log_model(
      sk_model=lr,
      name="iris_model",
      signature=signature,
      input_example=X_train,
      registered_model_name="tracking-quickstart",
  )

To minimize errors and increase compatibility, MLflow supports auto-logging; ChaM3Leon leverages this pattern with Scikit-learn, TensorFlow, and PyTorch (with ad-hoc management via PyTorch Lightning). In banking audits and research projects, lineage and reproducibility reduce ambiguities between runs and results.

When Does ChaM3Leon Utilize Apache Spark and Spark Connect for Distributed Processing?

ChaM3Leon utilizes Apache Spark (a distributed processing engine) when workflows require ETL over massive volumes, feature engineering on DataFrames, and parallel computing. Spark is composed of Spark SQL, Structured Streaming, MLlib, and GraphX; in ChaM3Leon, it is particularly useful for data-first pipelines where data preparation, rather than model training, is the bottleneck.

When developing with Spark, SparkSession and DataFrame are the most crucial elements. Example (preserved):

df = spark.read.json("logs.json")
df.where("age > 21").select("name.first").show()

In Docker or microservices environments, Spark Connect (a client-server interface for Spark) allows separating the client from the server, avoiding the constraints of spark-submit. This approach enables modular architectures but reduces access to certain parameters available in traditional submissons. A useful reference on reproducibility via "execution traces" in Python toolchains is the research on ET-CoT (OpenReview, 2025).


How Does Jinja2 Automate Flow Generation in ChaM3Leon?

Jinja2 (a Python template engine from the Pallets project) automates the generation of flow files in ChaM3Leon, transforming repeatable configurations into consistent Metaflow classes. The practical problem solved here is boilerplate: identical imports, the same step patterns, and identical decorators, but with variations in data sources, parameters, and naming. Using Jinja2, ChaM3Leon can scaffold standard pipelines in minutes, improving onboarding and consistency across teams.

A Jinja template can adapt dynamically to inputs, for instance, generating steps based on a list. Example (preserved) of rendering:

>>> t = env.from_string('[{% for item in data %}{{ item + 1 }},{% endfor %}]')
>>> result = t.render(data=range(5))
>>> print(result)
[1, 2, 3, 4, 5]

It is important to keep template code simple and readable. It is recommended to use templates only for repetitive structures and established blueprints, while application logic should be handled directly within the Python code.

Which Data Sources and External Tools Can ChaM3Leon Integrate?

ChaM3Leon integrates data sources and external tools through custom Metaflow decorators, providing a unified interface for reading/writing (both with and without PySpark). The main categories include relational databases (PostgreSQL), object storage (MinIO, Amazon S3), stream/event platforms (Apache Kafka), APIs (REST), tracking systems (MLflow), and distributed compute engines (Apache Spark). In banking and university environments, the objective is to reduce duplicate code and centralize configurations, credentials, and access policies.

Integration Type Examples Typical Use Case Implementation Notes
Databases PostgreSQL Feature store, batch queries Connections via config and conn_id
Object Storage MinIO, Amazon S3 Datasets and artifacts Manage credentials and bucket policies
Streaming Apache Kafka Event ingestion Schema and consumer compatibility
APIs REST API Data enrichment, scoring Timeouts, retries, and rate limits
Tracking MLflow Metrics and Model Registry Tracking URIs and permissions
Compute PySpark, Spark Connect Massive ETLs and joins Align client and server versions

The most frequent errors are schema mismatches (Kafka/SQL), unpropagated credentials (S3/MinIO), and inconsistent environment variables across containers. For a broader view on governance and compliance in AI workflows, see AI governance and EU AI Act compliance in enterprises and using digital twins for compliance traceability.

How Does ChaM3Leon Compare with Alternatives, and What are Its Limitations and Roadmap?

ChaM3Leon is a solid choice when a Python team wants to combine orchestration (Metaflow), tracking (MLflow), and processing (Spark) into a single framework; however, tools like Apache Airflow or Kubeflow may be better suited when the enterprise standard revolves around a general-purpose DAG scheduler or an end-to-end Kubernetes platform. In other words, ChaM3Leon optimizes integration and productivity on the chosen stack without replacing every single MLOps component.

Tool Core Unit Experiment Tracking Best Fit
ChaM3Leon Python Flow Integrated MLflow ML + data engineering pipelines
Apache Airflow DAG Scheduler External ETL and general-purpose orchestration
Kubeflow K8s Components Integrable ML platforms on Kubernetes
Metaflow-only Steps and artifacts External/Optional Simple and reproducible workflows

Typical Limitations: Initial complexity (configs, templates, credentials), maturity of the connector ecosystem, and the necessity to align library versions (Spark Connect, PyTorch). The "version pinning" issue is very real: enterprise models only reach a 48–51% success rate (2014–2023 dataset) (Hugging Face, 2024).

The dataset allows evaluating the compatibility of code generated by AI models with specific versions of Python libraries. It provides targeted examples to test the capacity of models to adapt to changes between library versions.

— GitChameleon 2.0 authors, Technical authors

Roadmap (Planned Directions): Evolving Jinja templates with Metaflow 2.18 features, supporting additional data sources beyond PostgreSQL/MinIO, expanding MLflow decorator support, and mutators to apply decorators based on naming patterns. To dive deeper into open-source licensing contexts, see understanding open source software and licensing.

Troubleshooting (3 Common Cases):

  • Dependency conflicts: Pin specific versions for PyTorch/Lightning and MLflow, and leverage reproducible builds (lockfiles).
  • Spark mismatch: Differing client/server versions in Spark Connect or parameters unavailable compared to a traditional spark-submit.
  • MLflow tracking: Incorrect URIs or insufficient permissions on the artifact store.

FAQ: ChaM3Leon Python Library

Is ChaM3Leon the same thing as the "Chameleon" Python library?

No, ChaM3Leon is a framework for MLOps workflows and data processing, whereas "Chameleon" often refers to a template engine or an unrelated project with a similar name in other contexts. Confusion typically arises from ambiguous queries and search results pointing to Pyramid templating or NLP research initiatives.

Where can I install ChaM3Leon (PyPI or GitHub)?

ChaM3Leon is installed directly from its official GitHub repository, not from PyPI. To access the repository, visit the ChaM3Leon GitHub page and follow the provided instructions to install via pip or git clone.

Which Python versions are supported?

ChaM3Leon generally follows the versions supported by its main dependencies like Metaflow, MLflow, PySpark, and core ML frameworks (Scikit-learn, TensorFlow, PyTorch). In practice, compatibility is decided down the chain: choose a Python version compatible with all required libraries and lock the versions to ensure reproducibility.

Is ChaM3Leon suitable for regulated environments like banks and universities?

Yes, ChaM3Leon is highly suitable when traceability, repeatability, and a clear separation between pipeline steps, artifacts, and metrics are required. Metaflow ensures executions are reproducible, while MLflow supports auditability through run histories and model registries. Ultimately, governance remains a responsibility of architecture and workflows.

What is the most common setup error with Spark Connect?

The most common error is a version mismatch between the client PySpark version and the Spark server version, often residing in different containers. The typical symptom is a SparkSession failing to initialize or breaking on basic operations. The fix consists of aligning images, dependencies, and network configurations.

How do I know if I should use ChaM3Leon or an alternative like Airflow or Kubeflow?

Use ChaM3Leon if your team works primarily in Python and needs out-of-the-box integration between orchestration, tracking, and distributed processing. Choose Airflow if your main priority is general ETL scheduling and an extensive ecosystem of operators. Choose Kubeflow if your organization standardizes entirely on Kubernetes and full-scale ML platforms.