Skip to content

Commit 1004441

Browse files
authored
Rename start to setup (#69)
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent 89527a3 commit 1004441

7 files changed

Lines changed: 31 additions & 30 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,18 @@ Run the following command for setup:
4545
cp .env.example .env & make up
4646
```
4747

48-
You can login to pgAdmin at `http://localhost:8080` to see the Postgres database. The host name for registering a new server is `postgres`, and the username and password are `alphatrion` and `alphatr1on`, respectively.
48+
You can login to pgAdmin at `http://localhost:8080` to see the Postgres database with following credentials:
4949

50-
**Note:**
51-
To log in to the pgAdmin web interface itself (before adding a server),
52-
use the default credentials defined in `docker-compose.yaml`:
53-
**Email:** `alphatrion@inftyai.com`
54-
**Password:** `alphatr1on`
50+
```shell
51+
Email: alphatrion@inftyai.com
52+
Username: alphatrion
53+
Password: alphatr1on
54+
Server: postgres
55+
```
5556

5657
### Run a Sample Experiment
5758

58-
Below is a simple example demonstrating how to create an experiment and log performance metrics.
59+
Below is a simple example with two approaches demonstrating how to create an experiment and log performance metrics.
5960

6061
```python
6162
import alphatrion as alpha
@@ -68,8 +69,8 @@ async def report():
6869
# Run your code here then log metrics.
6970
await alpha.log_metrics({"accuracy": 0.95})
7071

71-
async with alpha.CraftExperiment.start(name="my_first_experiment") as exp:
72-
async with exp.start_trial(name="my_first_trial") as trial:
72+
async with alpha.CraftExperiment.setup(name="my_first_experiment") as exp:
73+
async with exp.start_trial(name="my_trial") as trial:
7374
run = trial.start_run(lambda: report())
7475
await run.wait()
7576
```

alphatrion/experiment/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_trial(self, id: int) -> trial.Trial | None:
2929

3030
async def __aenter__(self):
3131
if self._id is None:
32-
raise RuntimeError("Experiment is not set. Did you call run()?")
32+
raise RuntimeError("Experiment is not set. Did you call start()?")
3333

3434
exp = self._get()
3535
if exp is None:
@@ -43,7 +43,7 @@ async def __aexit__(self, exc_type, exc_val, exc_tb):
4343

4444
@classmethod
4545
@abstractmethod
46-
def start(
46+
def setup(
4747
cls, name: str, description: str | None = None, meta: dict | None = None
4848
) -> "Experiment":
4949
"""Return a new experiment."""

alphatrion/experiment/craft_exp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def __init__(self):
1414
super().__init__()
1515

1616
@classmethod
17-
def start(
17+
def setup(
1818
cls,
1919
name: str,
2020
description: str | None = None,
2121
meta: dict | None = None,
2222
) -> "CraftExperiment":
2323
"""
24-
Begin the experiment. If the name already exists in the same project,
24+
Setup the experiment. If the name already exists in the same project,
2525
it will refer to the existing experiment instead of creating a new one.
2626
"""
2727

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "alphatrion"
3-
version = "0.0.1"
3+
version = "0.0.2"
44
description = "AlphaTrion is an open-source and all-in-one platform to build AI-powered applications."
55
license = {text = "Apache-2.0"}
66
readme = "README.md"

tests/integration/test_log.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
async def test_log_artifact():
1717
alpha.init(project_id=uuid.uuid4(), artifact_insecure=True, init_tables=True)
1818

19-
async with alpha.CraftExperiment.start(
19+
async with alpha.CraftExperiment.setup(
2020
name="log_artifact_exp",
2121
description="Context manager test",
2222
meta={"key": "value"},
@@ -68,7 +68,7 @@ async def test_log_artifact():
6868
async def test_log_params():
6969
alpha.init(project_id=uuid.uuid4(), artifact_insecure=True, init_tables=True)
7070

71-
async with alpha.CraftExperiment.start(name="log_params_exp") as exp:
71+
async with alpha.CraftExperiment.setup(name="log_params_exp") as exp:
7272
trial = exp.start_trial(name="first-trial", params={"param1": 0.1})
7373

7474
new_trial = exp._runtime._metadb.get_trial(trial_id=trial.id)
@@ -98,7 +98,7 @@ async def test_log_metrics():
9898
async def log_metric(metrics: dict):
9999
await alpha.log_metrics(metrics)
100100

101-
async with alpha.CraftExperiment.start(name="log_metrics_exp") as exp:
101+
async with alpha.CraftExperiment.setup(name="log_metrics_exp") as exp:
102102
trial = exp.start_trial(name="first-trial", params={"param1": 0.1})
103103

104104
new_trial = exp._runtime._metadb.get_trial(trial_id=trial._id)
@@ -145,7 +145,7 @@ async def test_log_metrics_with_save_on_max():
145145
async def log_metric(value: float):
146146
await alpha.log_metrics({"accuracy": value})
147147

148-
async with alpha.CraftExperiment.start(
148+
async with alpha.CraftExperiment.setup(
149149
name="log_metrics_with_save_on_max",
150150
description="Context manager test",
151151
meta={"key": "value"},
@@ -211,7 +211,7 @@ async def test_log_metrics_with_save_on_min():
211211
async def log_metric(value: float):
212212
await alpha.log_metrics({"accuracy": value})
213213

214-
async with alpha.CraftExperiment.start(
214+
async with alpha.CraftExperiment.setup(
215215
name="log_metrics_with_save_on_min",
216216
description="Context manager test",
217217
meta={"key": "value"},
@@ -280,7 +280,7 @@ async def fake_sleep(value: float):
280280
await asyncio.sleep(100)
281281
await alpha.log_metrics({"accuracy": value})
282282

283-
async with alpha.CraftExperiment.start(
283+
async with alpha.CraftExperiment.setup(
284284
name="log_metrics_with_early_stopping"
285285
) as exp:
286286
async with exp.start_trial(
@@ -317,7 +317,7 @@ async def fake_sleep(value: float):
317317
await asyncio.sleep(value)
318318
await alpha.log_metrics({"accuracy": value})
319319

320-
async with alpha.CraftExperiment.start(
320+
async with alpha.CraftExperiment.setup(
321321
name="log_metrics_with_both_early_stopping_and_timeout"
322322
) as exp:
323323
async with exp.start_trial(
@@ -346,7 +346,7 @@ async def test_log_metrics_with_max_run_number():
346346
async def fake_work(value: float):
347347
await alpha.log_metrics({"accuracy": value})
348348

349-
async with alpha.CraftExperiment.start(
349+
async with alpha.CraftExperiment.setup(
350350
name="log_metrics_with_max_run_number"
351351
) as exp:
352352
async with exp.start_trial(

tests/integration/test_tracing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def joke_workflow():
5252

5353
@pytest.mark.asyncio
5454
async def test_workflow():
55-
async with alpha.CraftExperiment.start("demo_joke_workflow") as exp:
55+
async with alpha.CraftExperiment.setup("demo_joke_workflow") as exp:
5656
async with exp.start_trial("demo_joke_trial") as trial:
5757
task = trial.start_run(lambda: joke_workflow())
5858
await task.wait()

tests/unit/experiment/test_craft_exp.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
async def test_craft_experiment():
1616
init(project_id=uuid.uuid4(), artifact_insecure=True, init_tables=True)
1717

18-
async with CraftExperiment.start(
18+
async with CraftExperiment.setup(
1919
name="context_exp",
2020
description="Context manager test",
2121
meta={"key": "value"},
@@ -43,7 +43,7 @@ async def fake_work(trial: Trial):
4343
await asyncio.sleep(3)
4444
trial.cancel()
4545

46-
exp = CraftExperiment.start(name="no_context_exp")
46+
exp = CraftExperiment.setup(name="no_context_exp")
4747
async with exp.start_trial(name="first-trial") as trial:
4848
trial.start_run(lambda: fake_work(trial))
4949
await trial.wait()
@@ -56,7 +56,7 @@ async def test_create_experiment_with_trial():
5656
init(project_id=uuid.uuid4(), artifact_insecure=True, init_tables=True)
5757

5858
trial_id = None
59-
async with CraftExperiment.start(name="context_exp") as exp:
59+
async with CraftExperiment.setup(name="context_exp") as exp:
6060
async with exp.start_trial(name="first-trial") as trial:
6161
trial_obj = trial._get_obj()
6262
assert trial_obj is not None
@@ -76,7 +76,7 @@ async def fake_work(trial: Trial):
7676
trial.cancel()
7777

7878
trial_id = None
79-
async with CraftExperiment.start(name="context_exp") as exp:
79+
async with CraftExperiment.setup(name="context_exp") as exp:
8080
async with exp.start_trial(name="first-trial") as trial:
8181
trial_id = current_trial_id.get()
8282
start_time = datetime.now()
@@ -100,7 +100,7 @@ async def fake_work(cancel_func: callable):
100100
cancel_func()
101101

102102
async with (
103-
CraftExperiment.start(name="context_exp") as exp,
103+
CraftExperiment.setup(name="context_exp") as exp,
104104
exp.start_trial(name="first-trial") as trial,
105105
):
106106
start_time = datetime.now()
@@ -123,7 +123,7 @@ async def fake_work(cancel_func: callable):
123123
async def test_craft_experiment_with_context():
124124
init(project_id=uuid.uuid4(), artifact_insecure=True, init_tables=True)
125125

126-
async with CraftExperiment.start(
126+
async with CraftExperiment.setup(
127127
name="context_exp",
128128
description="Context manager test",
129129
meta={"key": "value"},
@@ -160,7 +160,7 @@ async def fake_work():
160160
trial = trial._get_obj()
161161
assert trial.status == TrialStatus.FINISHED
162162

163-
async with CraftExperiment.start(
163+
async with CraftExperiment.setup(
164164
name="context_exp",
165165
description="Context manager test",
166166
meta={"key": "value"},

0 commit comments

Comments
 (0)