Skip to main content

A Python package with Rust extensions

Project description

Firehot

Firehot

A package to quickly hot reload large Python projects. Currently in development.

Background

Once your project gets to a certain size, the main overhead of application startup is typically the loading of 3rd party packages. Packages can do varying degrees of global initialization when they're imported. They can also require 100s or 1000s of additional files, which the AST parser has to step through one by one. Cached bytecode can help but it's not a silver bullet.

Eventually your bootup can take 5-10s just to load these modules. Fine for a production service that's intended to run continuously, but horrible for a development experience when you have to reboot after changes. Firehot solves this by importing dependencies once, then forking your environment for each exec. Think of it like building a docker image then executing it whenever you make a change.

Python Usage

from firehot import isolate_imports
from os import getpid, getppid

def run_under_environment(value: int):
   parent_pid = getppid()
   print(f"Running with value: {value} (pid: {getpid()}, parent_pid: {parent_pid})")

with isolate_imports("my_package") as environment:
   # Each exec will be run in a new process with the environment isolated, inheriting
   # the package's third party imports without having to re-import them from scratch.
   context1 = environment.exec(run_under_environment, 1)
   context2 = environment.exec(run_under_environment, 2)

   # These can potentially be long running - to wait on the completion status, you can do:
   result1 = environment.communicate_isolated(context1)
   result2 = environment.communicate_isolated(context2)

   # If you change the underlying file on disk to add an import, you can run update_environment.
   # If the files on disk don't add any new imports, it will be a no-op and keep the current
   # environment process running.
   environment.update_environment()

   # Subsequent execs will use the updated environment.
   context3 = environment.exec(run_under_environment, 3)
   result3 = environment.communicate_isolated(context3)

Logging

By default, Firehot logs at the warn level, but you can adjust this by setting the FIREHOT_LOG_LEVEL environment variable. Most of these logs come from the Rust code.

Available log levels (from most to least verbose):

  • trace: Extremely detailed information, useful for debugging specific issues
  • debug: Detailed information useful during development
  • info: General information about what's happening (default)
  • warn: Warning messages for potential issues
  • error: Error messages for actual problems

Example usage:

# Set to debug level for more detailed logs
FIREHOT_LOG_LEVEL=debug python your_script.py

# Set to error level for minimal logs
FIREHOT_LOG_LEVEL=error python your_script.py

Architecture

You launch Firehot by pointing it to your package name, which we resolve internally to a disk path that contains your code. From there, our Rust logic takes over. The pipeline will parse this directory recursively for all Python files, then parse the code's AST to determine which imports are used by your project.

It will then launch a continuously running process that caches only the 3rd party packages/modules. We think of this as the "template" process because it establishes the environment that will be used to run your code. None of your user code is run in this process.

When code changes are made in your project, we will:

  • Determine if your changes affected the imported packages
  • If not, we can fork the parent process and pass in your user code. This will load all modules from scratch, but because importlib caches the modules in global space, it will be a no-op because of the template.
  • If so, we will tear down the current parent process and start a new one with the full 3rd party packages imported. Then we'll fork the environment as normal.

Local Experiments

To test how firehot works with a real project, we bundle a mypackage and external-package library in this repo.

make
uv run test-hotreload

Unit tests

cargo test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firehot-0.1.0.tar.gz (19.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

firehot-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

firehot-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

firehot-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

firehot-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

firehot-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

firehot-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

firehot-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

firehot-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

firehot-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.39+ x86-64

firehot-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (1.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file firehot-0.1.0.tar.gz.

File metadata

  • Download URL: firehot-0.1.0.tar.gz
  • Upload date:
  • Size: 19.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for firehot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba18eb881b60c43c7d4bc685a1c0e60f4da64e6f657728bbd6f21e6657935db4
MD5 8ecb7fb0f2f81b6e4869fff63537aa2e
BLAKE2b-256 db9766b6925781a5a87f172f5d6ea5fba38d674a647be64ee1f8d4caac24b18a

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0.tar.gz:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 07226d3d27377c311692f06ce717b49237dcc00874d1ef467c43c43206a366fe
MD5 1fc604d17beef614b8d139e2152f6f15
BLAKE2b-256 77398764d2206d0a851d27b6101a10698ebef5c71a85885e9abdba6b488495b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp313-cp313-manylinux_2_39_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c08e53f6f11dafcdcfab62f859bc081bd1333661afc376b87e5516e2761672a0
MD5 4278fe95552c9b18dafd1b901b8a93c3
BLAKE2b-256 c55a9263e92ad7fcc5f930e5bf3e7d0317605cff45f545409330c55375d8c466

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 04e64353c1fd26f138ef1d7936d3d5e90215eb6a37e01b65be1128b1a37dd742
MD5 c4aa8b9c97e1f535b60199e07ccd33e5
BLAKE2b-256 ddd082b6a42dc7417d50029aff5cc5136a5c7793f969b7608598ed80d0fc6e8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44babc3bfe736c200ffe74f95fa08c0aef053f9c3435a65853cc345dcef99955
MD5 4e1118d6dd4a2e7c2d0f0cd152171d5e
BLAKE2b-256 e17159536a3dcea4694f246254499c6d602d8f2d9fe440747400645f5dd5d90e

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 666c9620bc92afbcf6542ba53e22263de106c155a64475531a73306db1e7821d
MD5 7a7ec79a2b7ef180999237fad7847dc1
BLAKE2b-256 62c0b9c193fa151935048ff9a0f37fcc7d5be386881675aef7510a34df65c7b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a2086f694f2d1f60bc989010b0f5fe6c57b85e1a9705b4507f89ea0d9051af58
MD5 72c1be77998479b69dc69ea21532292d
BLAKE2b-256 fbbcd3a26193d094cb57ba39f0e642c15ce71e664fb5f86376476ed476474c31

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 28d75aeb6fb946e2702f2cc0f2a51a031ccbe4d2eef3498a139afd2feeefddec
MD5 fbf57c715c062c7f024050e92605bb04
BLAKE2b-256 584b3f09c4b1c7113ecf122e6869ddefa4f24a16fc521623a0787a2e0f85d918

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bab4c650e2111d985403031e3c9c8c192f060438b71322ca8b1af0ec784a39a6
MD5 6240cfc2828f0c2b36b975cc04fdc067
BLAKE2b-256 0b3152208f1c3e1c3f1f4d9cfc87e2e5b2c76ffd300d240a40019b138d928bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c2b8edba11f1c13f706bbeff0e092ee577424d7aa349ee6be3a2116748245960
MD5 e4f655393bd73ab169b47deca180e171
BLAKE2b-256 feb6ba2e2166e960b652f0ae31b4ea5c289c8565aa4fc95c79eaa9d61c7b26e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp39-cp39-manylinux_2_39_x86_64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firehot-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for firehot-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ce58cf60b88f150fa78b95ee23ca951b4d61c5cef37646411dfc0f168627a15
MD5 8b1dc6369c41c160dbc21c5ff5aeaba7
BLAKE2b-256 04e63b2cb0f1d283e7df6c4c8b3d16799e837069b15a188d48ff40fa1e840b0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for firehot-0.1.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: ci-build.yml on piercefreeman/firehot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page