diff --git a/README.md b/README.md index de85b9d6..e76fdffc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,19 @@ -# AlphaTrion +

+ + + alphatrion + +

+ +

+Open, modular framework to build GenAI applications. +

+ +[![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 @@ -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) \ No newline at end of file diff --git a/alphatrion/experiment/base.py b/alphatrion/experiment/base.py index 285e8225..7a68deac 100644 --- a/alphatrion/experiment/base.py +++ b/alphatrion/experiment/base.py @@ -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( @@ -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, @@ -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()}" @@ -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 @@ -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, @@ -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, @@ -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 diff --git a/docs/development.md b/site/docs/development.md similarity index 100% rename from docs/development.md rename to site/docs/development.md diff --git a/docs/roadmap.md b/site/docs/roadmap.md similarity index 100% rename from docs/roadmap.md rename to site/docs/roadmap.md diff --git a/docs/troubleshooting.md b/site/docs/troubleshooting.md similarity index 100% rename from docs/troubleshooting.md rename to site/docs/troubleshooting.md diff --git a/site/images/alphatrion.png b/site/images/alphatrion.png new file mode 100644 index 00000000..4a9a11f2 Binary files /dev/null and b/site/images/alphatrion.png differ diff --git a/site/images/logo.png b/site/images/logo.png new file mode 100644 index 00000000..11ec3dc7 Binary files /dev/null and b/site/images/logo.png differ diff --git a/tests/unit/experiment/test_craft_exp.py b/tests/unit/experiment/test_craft_exp.py index d4a17c65..5b96db2f 100644 --- a/tests/unit/experiment/test_craft_exp.py +++ b/tests/unit/experiment/test_craft_exp.py @@ -1,3 +1,5 @@ +import time + from alphatrion.experiment.craft_exp import CraftExperiment from alphatrion.metadata.sql_models import ExperimentStatus @@ -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