Metadata-Version: 2.4
Name: hyrex
Version: 0.9.7
Summary: Hyrex is the open-source COLD task orchestration framework built on Postgres.
Author-email: Trevor Reed <trevor@hyrex.io>, Mark Dawson <mark@hyrex.io>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/hyrex-labs/hyrex-python
Project-URL: Source Code, https://github.com/hyrex-labs/hyrex-python
Keywords: hyrex,task,queue,async
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: annotated-types>=0.7.0
Requires-Dist: click==8.1.7
Requires-Dist: croniter>=6.0.0
Requires-Dist: boto3>=1.35.98
Requires-Dist: grpcio>=1.71.0
Requires-Dist: protobuf<6.0.0,>=5.29.0
Requires-Dist: psycopg[binary,pool]>=3.2.1
Requires-Dist: pydantic>=2.8.2
Requires-Dist: pydantic_core>=2.20.1
Requires-Dist: requests>=2.32.3
Requires-Dist: SQLAlchemy>=2.0.31
Requires-Dist: sqlmodel>=0.0.21
Requires-Dist: typer==0.15.3
Requires-Dist: typing_extensions>=4.12.2
Requires-Dist: uuid7>=0.1.0
Provides-Extra: dev
Requires-Dist: black>=22.3.0; extra == "dev"
Dynamic: license-file

# hyrex-sdk

Hyrex is a modern, open-source task orchestration framework.

## Installation

`pip install hyrex`

### Running on your own infra:

#### Step 1: Database initialization

- Set `HYREX_DATABASE_URL` to your Postgres database connection string
- Run `hyrex init-db`

#### Step 2: Decorate your tasks

- Instantiate a Hyrex object wherever your tasks are defined:

```
from hyrex import Hyrex

hy = Hyrex(app_id="my-hyrex-app")
```

- Decorate your task:

```
def NameContext(BaseModel):
    name: str


@hy.task
def say_name(context: NameContext):
    print(context.name)
```

- Send your task to the Hyrex queue. A worker will pick it up from there.

```
say_name.send(NameContext(name="Bob"))
```

#### Step 3: Run your worker(s)

- Make sure `HYREX_DATABASE_URL` is set.
- Update this command with the module path to your Hyrex instance:

```
hyrex run-worker my_app.tasks:hy
```

## Logging

Hyrex uses Python's `logging` module for logging info about task queueing, worker status, etc.
By default, no logs are displayed. To turn on logs, configure this in your application. For example:

```
import logging
logging.basicConfig(level=logging.INFO)
```

To configure Hyrex logs only:

```
logger = logging.getLogger("hyrex")
logger.setLevel(logging.INFO)
```

Handlers and formatting options from the `logging` module are also supported.

For worker processes, the logging level can be set using the `log-level` flag on the `hyrex run-worker` CLI command.
