Skip to main content

Chronon Python API

Overview

Chronon Python API for materializing configs to be run by the Chronon Engine. Contains python helpers to help managed a repo of feature and join definitions to be executed by the chronon scala engine.

User API Overview

Sources

Most fields are self explanatory. Time columns are expected to be in milliseconds (unixtime).

# File <repo>/sources/sample_sources.py
from ai.chronon.query import (
  Query,
  select,
)
from ai.chronon.source import EventSource, EntitySource

# Sample query
Query(
  selects=select(
      user="user_id",
      created_at="created_at",
  ),
  wheres=["has_availability = 1"],
  start_partition="2021-01-01",  # Defines the beginning of time for computations related to the source.
  setups=["...UDF..."],
  time_column="ts",
  end_partition=None,
  mutation_time_column="mutation_timestamp",
  reversal_column="CASE WHEN mutation_type IN ('DELETE', 'UPDATE_BEFORE') THEN true ELSE false END"
)

user_activity = EntitySource(
  snapshot_table="db_exports.table",
  mutation_table="mutations_namespace.table_mutations",
  mutation_topic="mutationsKafkaTopic",
  query=Query(...)
)

website__views = EventSource(
  table="namespace.table",
  topic="kafkaTopicForEvents",
)
Group By (Features)

Group Bys are aggregations over sources that define features. For example:

# File <repo>/group_bys/example_team/example_group_by.py
from ai.chronon.group_by import (
  GroupBy,
  Window,
  TimeUnit,
  Accuracy,
  Operation,
  Aggregations,
  Aggregation,
  DefaultAggregation,
)
from sources import sample_sources

sum_cols = [f"active_{x}_days" for x in [30, 90, 120]]


v0 = GroupBy(
  sources=test_source.user_activity,
  keys=["user"],
  aggregations=Aggregations(
    user_active_1_day=Aggregation(operation=Operation.LAST),
    second_feature=Aggregation(
      input_column="active_7_days",
      operation=Operation.SUM,
      windows=[
        Window(n, TimeUnit.DAYS) for n in [3, 5, 9]
      ]
    ),
  ) + [
    Aggregation(
      input_column=col,
      operation=Operation.SUM
    ) for col in sum_columns           # Alternative syntax for defining aggregations.
  ] + [
    Aggregation(
      input_column="device",
      operation=LAST_K(10)
    )
  ],
  dependencies=[
    "db_exports.table/ds={{ ds }}"      # If not defined will be derived from the Source info.
  ],
  accuracy=Accuracy.SNAPSHOT,          # This could be TEMPORAL for point in time correctness.
  env={
    "backfill": {                      # Execution environment variables for each of the modes for `run.py`
      "EXECUTOR_MEMORY": "4G"
     },
  },
  online=True,                         # True if this group by needs to be uploaded to a KV Store.
  production=False                     # True if this group by is production level.
)
Join

A Join is a collection of feature values for the keys and (times if applicable) defined on the left (source). Example:

# File <repo>/joins/example_team/example_join.py
from ai.chronon.join import Join, JoinPart
from sources import sample_sources
from group_bys.example_team import example_group_by

v1 = Join(
    left=sample_sources.website__views,
    right_parts=[
        JoinPart(group_by=example_group_by.v0),
    ],
    online=True,       # True if this join will be fetched in production.
    production=False,  # True if this join should not use non-production group bys.
    env={"backfill": {"PARALLELISM": "10"}, "streaming": {"STREAMING_ENV_VAR": "VALUE"}},
)
Compile

zipline compile turns authored configs (under group_bys/, joins/, staging_queries/, models/, model_transforms/) into thriftjson under compiled/. The compiler reads team-level defaults (output namespace, env vars, conf, cluster config, and execution info) from teams.py and merges them onto each config's metaData.executionInfo.

zipline compile --chronon-root <repo-root>
Multi-environment compile via teams.canary.py

To compile the same configs against a canary deployment, drop a sibling teams.canary.py next to teams.py. zipline compile will run a second pass and write to compiled_canary/. Only canary is supported as a non-prod env today.

See the Multi-Environment Compile & Deploy guide for the full guide — directory layout, the from teams import … authoring pattern, per-entity environments=[...] opt-in, the --env deploy contract, the compile summary, and the CI workflow.

Pre-commit Setup
  1. Install pre-commit and other dev libraries:
pip install -r requirements/dev.txt
  1. Run the following command under api/python to install the git hook scripts:
pre-commit install

To support more pre-commit hooks, add them to the .pre-commit-config.yaml file.

Release files for zipline-ai 1.23.0

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

Built distribution (wheel)

Table of built distributions (wheels) for zipline-ai 1.23.0
File Interpreter ABI Platform
zipline_ai-1.23.0-py3-none-any.whl Python 3 none any Details

Release files / zipline_ai-1.23.0-py3-none-any.whl

Download URL zipline_ai-1.23.0-py3-none-any.whl
Size 333.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
603c490c4baed9ec4d908fa48c86cf07a60fd26728537058ad08651c1240b59a
BLAKE2b-256 checksum
How to use checksums
0715c421ac94fbeb1609ed4afc1bc26e6e13c1ce176f9ca228e913882f6e66af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

1.25.0

1 release file

1.24.1

1 release file

1.24.0

1 release file

1.23.4

1 release file

1.23.3

1 release file

1.23.2

1 release file

1.23.1

1 release file

This release

1.23.0 This release

1 release file

1.22.0

1 release file

1.21.2

1 release file

1.21.1

1 release file

1.20.1

1 release file

1.20.0

1 release file

1.19.1

1 release file

1.19.0

1 release file

1.18.1

1 release file

1.18.0

1 release file

1.17.7

1 release file

1.17.6

1 release file

1.17.5

1 release file

1.17.4

1 release file

1.17.3

1 release file

1.17.2

1 release file

1.17.1

1 release file

1.17.0

1 release file

1.16.2

1 release file

1.16.1

1 release file

1.16.0

1 release file

1.15.2

1 release file

1.15.1

1 release file

1.15.0

1 release file

1.14.1

1 release file

1.14.0

1 release file

1.13.0

1 release file

1.12.2

1 release file

1.12.1

1 release file

1.12.0

1 release file

1.11.0

1 release file

1.10.7

1 release file

1.10.6

1 release file

1.10.5

1 release file

1.10.4

1 release file

1.10.3

1 release file

1.10.2

1 release file

1.10.1

1 release file

1.10.0

1 release file

1.9.1

1 release file

1.9.0

1 release file

1.8.5

1 release file

1.8.4

1 release file

1.8.3

1 release file

1.8.2

1 release file

1.8.1

1 release file

1.8.0

1 release file

1.7.0

1 release file

1.6.0

1 release file

1.5.0

1 release file

1.4.2

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.2

1 release file

1.3.1

1 release file

1.3.0

1 release file

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.21

1 release file

1.0.20

1 release file

1.0.19

1 release file

1.0.18

1 release file

1.0.17

1 release file

1.0.16

1 release file

1.0.15

1 release file

1.0.14

1 release file

1.0.13

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

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