Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# AlphaTrion
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/inftyai/alphatrion/main/site/images/alphatrion.png">
<img alt="alphatrion" src="https://raw.githubusercontent.com/inftyai/alphatrion/main/site/images/alphatrion.png" width=55%>
</picture>
</p>

<h3 align="center">
Open, modular framework to build GenAI applications.
</h3>

[![stability-alpha](https://img.shields.io/badge/stability-alpha-f4d03f.svg)](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#alpha)
[![Latest Release](https://img.shields.io/github/v/release/inftyai/alphatrion?include_prereleases)](https://github.com/inftyai/alphatrion/releases/latest)

**AlphaTrion** is an open-source and all-in-one platform to build LLM-powered applications and frameworks. Named after the oldest and wisest Transformer mentor, it embodies guidance and innovation to help developers build **production-ready** GenAI applications and frameworks with ease. *Still under active development.*

**AlphaTrion** is an open-source and all-in-one platform to build LLM-powered applications and frameworks. Named after the wise Transformer mentor, it embodies guidance and innovation to help developers build **production-ready** GenAI applications with ease. *Still under active development.*

## How to Install

Expand All @@ -12,20 +25,20 @@ pip install alphatrion

### Install from Source

Refer to [developer.md](./docs/development.md) for more information on how to set up your development environment.
Refer to [developer.md](./site/docs/development.md) for more information on how to set up your development environment.

## Quick Start

Still under active development now.

Refer to [troubleshooting.md](./docs/troubleshooting.md) for common issues and solutions which may help.
Refer to [troubleshooting.md](./site/docs/troubleshooting.md) for common issues and solutions which may help.

## How to Contribute

We welcome all kinds of contributions! Please see our [contribution guidelines](CONTRIBUTING.md) for more details.

Refer to [developer.md](./docs/development.md) for more information on how to set up your development environment.
Refer to [developer.md](./site/docs/development.md) for more information on how to set up your development environment.

Refer to [our roadmap](./docs/roadmap.md) to see what features are coming next.
Refer to [our roadmap](./site/docs/roadmap.md) to see what features are coming next.

[![Star History Chart](https://api.star-history.com/svg?repos=inftyai/alphatrion&type=Date)](https://www.star-history.com/#inftyai/alphatrion&Date)
26 changes: 25 additions & 1 deletion alphatrion/experiment/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ def __init__(self, runtime: Runtime, config: ExperimentConfig | None = None):
self._runtime = runtime
self._artifact = Artifact(runtime)
self._config = config or ExperimentConfig()

self._steps = 0
self._start_at = None
self._best_metric_value = None
# Start time of the experiment. Set when experiment is started,
# reset to None when experiment is stopped.
self._start_at = None

@classmethod
def run(
Expand All @@ -103,6 +106,11 @@ def create(
meta: dict | None = None,
labels: dict | None = None,
):
"""
Create a new experiment in the metadata store.
Returns the experiment ID.
"""

exp_id = self._runtime._metadb.create_exp(
name=name,
description=description,
Expand Down Expand Up @@ -138,6 +146,11 @@ def start(
meta: dict | None = None,
labels: dict | None = None,
) -> int:
"""
Start a new experiment. If name is not provided, a UUID will be generated.
Returns the experiment ID.
"""

if name is None:
name = f"{uuid.uuid4()}"

Expand All @@ -147,6 +160,7 @@ def start(
meta=meta,
labels=labels,
)

self._runtime._metadb.update_exp(exp_id=exp_id, status=ExperimentStatus.RUNNING)
self._start_at = datetime.now(UTC)
return exp_id
Expand All @@ -168,6 +182,12 @@ def reset(self):
self._start_at = None
self._best_metric_value = None

# running time in seconds since the experiment is started.
def running_time(self) -> int:
if self._start_at is None:
return 0
return int((datetime.now(UTC) - self._start_at).total_seconds())

# def save_checkpoint(
# self,
# exp_id: int,
Expand Down Expand Up @@ -198,6 +218,9 @@ def __init__(
self._meta = meta
self._labels = labels

# Set when start the context, reset to None when exit the context.
self._exp_id = None

def __enter__(self):
self._exp_id = self._experiment.start(
name=self._exp_name,
Expand All @@ -210,3 +233,4 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
self._experiment.stop(self._exp_id)
self._experiment.reset()
self._exp_id = None
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added site/images/alphatrion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added site/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions tests/unit/experiment/test_craft_exp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

from alphatrion.experiment.craft_exp import CraftExperiment
from alphatrion.metadata.sql_models import ExperimentStatus

Expand All @@ -10,12 +12,17 @@ def test_run_context():
meta={"key": "value"},
labels={"type": "unit"},
) as exp:
time.sleep(1)
assert exp.running_time() == 1

exp1 = exp.get(1)
assert exp1 is not None
assert exp1.name == "context_exp"
assert exp1.description == "Context manager test"
assert exp1.status == ExperimentStatus.RUNNING

assert exp.running_time() == 0

exp1 = exp.get(1)
assert exp1.status == ExperimentStatus.FINISHED
assert exp1.duration > 0
Expand Down
Loading