Skip to content

Commit

Permalink
Update examples after methods renaming (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
vhaldemar committed Jan 27, 2025
1 parent d54de68 commit bad0781
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 137 deletions.
5 changes: 2 additions & 3 deletions examples/async/tuning/attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = await dataset_draft.upload()
dataset = await operation
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/basic_train_and_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = await dataset_draft.upload()
dataset = await operation
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/binary_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ async def get_datasets(sdk):
else:
print('no old datasets found, creating new one')
# NB: yeah, dataset type is still text_classifiers_multiclass
dataset_draft = sdk.datasets.text_classifiers_binary.from_path_deferred(
dataset_draft = sdk.datasets.text_classifiers_binary.draft_from_path(
path=local_path('binary_classification.jsonlines'),
upload_format='jsonlines',
name='binary',
)

operation = await dataset_draft.upload()
dataset = await operation.wait()
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = await dataset_draft.upload()
dataset = await operation
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = await dataset_draft.upload()
dataset = await operation
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/multiclass_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.text_classifiers_multiclass.from_path_deferred(
dataset_draft = sdk.datasets.text_classifiers_multiclass.draft_from_path(
path=local_path('multiclass_classification.jsonlines'),
upload_format='jsonlines',
name='multiclass',
)

operation = await dataset_draft.upload()
dataset = await operation.wait()
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/multilabel_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.text_classifiers_multilabel.from_path_deferred(
dataset_draft = sdk.datasets.text_classifiers_multilabel.draft_from_path(
path=local_path('multilabel_classification.jsonlines'),
upload_format='jsonlines',
name='multilabel',
)

operation = await dataset_draft.upload()
dataset = await operation.wait()
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = await dataset_draft.upload()
dataset = await operation
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/async/tuning/tuning_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ async def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = await dataset_draft.upload()
dataset = await operation
dataset = await dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/sync/tuning/attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/sync/tuning/basic_train_and_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/sync/tuning/binary_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ def get_datasets(sdk):
else:
print('no old datasets found, creating new one')
# NB: yeah, dataset type is still text_classifiers_multiclass
dataset_draft = sdk.datasets.text_classifiers_binary.from_path_deferred(
dataset_draft = sdk.datasets.text_classifiers_binary.draft_from_path(
path=local_path('binary_classification.jsonlines'),
upload_format='jsonlines',
name='binary',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/sync/tuning/cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
11 changes: 5 additions & 6 deletions examples/sync/tuning/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,23 @@ def main() -> None:
folder_id='b1ghsjum2v37c2un8h64',
)

dataset_draft = sdk.datasets.from_path_deferred(
dataset_draft = sdk.datasets.draft_from_path(
task_type='TextToTextGeneration',
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'new {dataset=}')

dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
local_path('example_bad_dataset')
)
dataset_draft.upload_format = 'jsonlines'
dataset_draft.name = 'foo'

operation = dataset_draft.upload()
operation = dataset_draft.upload_deferred()
try:
dataset = operation.wait()
except DatasetValidationError as error:
Expand All @@ -43,7 +42,7 @@ def main() -> None:
print(f"going to delete {bad_dataset=}")
bad_dataset.delete()

operation = dataset_draft.upload(raise_on_validation_failure=False)
operation = dataset_draft.upload_deferred(raise_on_validation_failure=False)
bad_dataset = operation.wait()
print(f"New {bad_dataset=} have a bad status {dataset.status=}")
dataset.delete()
Expand Down
5 changes: 2 additions & 3 deletions examples/sync/tuning/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.completions.from_path_deferred(
dataset_draft = sdk.datasets.completions.draft_from_path(
path=local_path('completions.jsonlines'),
upload_format='jsonlines',
name='completions',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
77 changes: 0 additions & 77 deletions examples/sync/tuning/multiclass.py

This file was deleted.

5 changes: 2 additions & 3 deletions examples/sync/tuning/multiclass_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.text_classifiers_multiclass.from_path_deferred(
dataset_draft = sdk.datasets.text_classifiers_multiclass.draft_from_path(
path=local_path('multiclass_classification.jsonlines'),
upload_format='jsonlines',
name='multiclass',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
5 changes: 2 additions & 3 deletions examples/sync/tuning/multilabel_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ def get_datasets(sdk):
break
else:
print('no old datasets found, creating new one')
dataset_draft = sdk.datasets.text_classifiers_multilabel.from_path_deferred(
dataset_draft = sdk.datasets.text_classifiers_multilabel.draft_from_path(
path=local_path('multilabel_classification.jsonlines'),
upload_format='jsonlines',
name='multilabel',
)

operation = dataset_draft.upload()
dataset = operation.wait()
dataset = dataset_draft.upload()
print(f'created new dataset {dataset=}')

return dataset, dataset
Expand Down
Loading

0 comments on commit bad0781

Please sign in to comment.