Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tuning.list example #38

Merged
merged 1 commit into from
Dec 6, 2024
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
11 changes: 7 additions & 4 deletions examples/async/tuning/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,25 @@ async def main() -> None:
base_model = sdk.models.completions('yandexgpt-lite')

task_ids = set()
for _ in range(1):
for _ in range(3):
tuning_task = await base_model.tune_deferred(
train_dataset,
validation_datasets=validation_dataset,
name=str(uuid.uuid4())
)
print(f'created task {tuning_task.id=}')
task_ids.add(tuning_task.id)

# NB: tuning tasks have a time gap, before they will
# be available at the backend as a `TuningTasks`
await asyncio.sleep(5)

print('And now - cancel all created tasks:')
async for tuning_task in sdk.tuning.list():
# or you could wait for tasks, instead of canceling
print(f'found task {tuning_task=}, canceling')
await tuning_task.cancel()
if tuning_task.id in task_ids:
# or you could wait for tasks, instead of canceling
print(f'found task {tuning_task=}, canceling')
await tuning_task.cancel()


if __name__ == '__main__':
Expand Down
11 changes: 7 additions & 4 deletions examples/sync/tuning/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,25 @@ def main() -> None:
base_model = sdk.models.completions('yandexgpt-lite')

task_ids = set()
for _ in range(1):
for _ in range(3):
tuning_task = base_model.tune_deferred(
train_dataset,
validation_datasets=validation_dataset,
name=str(uuid.uuid4())
)
print(f'created task {tuning_task.id=}')
task_ids.add(tuning_task.id)

# NB: tuning tasks have a time gap, before they will
# be available at the backend as a `TuningTasks`
time.sleep(5)

print('And now - cancel all created tasks:')
for tuning_task in sdk.tuning.list():
# or you could wait for tasks, instead of canceling
print(f'found task {tuning_task=}, canceling')
tuning_task.cancel()
if tuning_task.id in task_ids:
# or you could wait for tasks, instead of canceling
print(f'found task {tuning_task=}, canceling')
tuning_task.cancel()


if __name__ == '__main__':
Expand Down
Loading