finetuner.client.client module#

class finetuner.client.client.FinetunerV1Client[source]#

Bases: _BaseClient

The Finetuner v1 API client.

create_experiment(name='default', description='')[source]#

Create a new experiment.

Parameters:
  • name (str) – The name of the experiment.

  • description (Optional[str]) – Optional description of the experiment.

Return type:

Dict[str, Any]

Returns:

Created experiment.

get_experiment(name)[source]#

Get an experiment by its name.

Parameters:

name (str) – The name of the experiment.

Return type:

dict

Returns:

Requested experiment.

list_experiments(page=1, size=50)[source]#

List every experiment.

Parameters:
  • page (int) – The page index.

  • size (int) – The number of experiments to retrieve.

Return type:

Dict[str, Any]

Returns:

Paginated results as a dict, where items are the `Experiment`s being retrieved.

..note:: page and size works together. For example, page 1 size 50 gives

the 50 experiments in the first page. To get 50-100, set page as 2.

..note:: The maximum number for size per page is 100.

delete_experiment(name)[source]#

Delete an experiment given its name.

Parameters:

name (str) – The name of the experiment.

Return type:

Dict[str, Any]

Returns:

Experiment to be deleted.

delete_experiments()[source]#

Delete all experiments.

Return type:

List[dict]

Returns:

Experiments to be deleted.

get_run(experiment_name, run_name)[source]#

Get a run by its name and experiment.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Return type:

dict

Returns:

Requested run.

list_runs(experiment_name=None, page=50, size=50)[source]#

List all created runs inside a given experiment.

If no experiment is specified, list runs for all available experiments. :type experiment_name: Optional[str] :param experiment_name: The name of the experiment. :type page: int :param page: The page index. :type size: int :param size: Number of runs to retrieve. :rtype: Dict[str, Any] :return: Paginated results as a dict, where items are the Runs being

retrieved.

..note:: page and size works together. For example, page 1 size 50 gives

the 50 runs in the first page. To get 50-100, set page as 2.

..note:: The maximum number for size per page is 100.

delete_run(experiment_name, run_name)[source]#

Delete a run by its name and experiment.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Return type:

Dict[str, Any]

Returns:

Deleted run.

delete_runs(experiment_name)[source]#

Delete all runs inside a given experiment.

Parameters:

experiment_name (str) – The name of the experiment.

Return type:

List[dict]

Returns:

List of all deleted runs.

get_run_status(experiment_name, run_name)[source]#

Get a run status by its name and experiment.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Return type:

dict

Returns:

Run status.

get_run_logs(experiment_name, run_name)[source]#

Get a run logs by its name and experiment.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Return type:

str

Returns:

Run logs.

stream_run_logs(experiment_name, run_name)[source]#

Streaming log events to the client as ServerSentEvents.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Yield:

A log entry.

Return type:

Iterator[str]

get_run_metrics(experiment_name, run_name)[source]#

Get evaluation metrics of a run by its name and experiment. This is only possible after the run has successfully finished.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Return type:

Dict[str, Any]

Returns:

Dict of metrics before and after fine-tuning

get_run_examples(experiment_name, run_name)[source]#

Get results of example queries of a run by the run’s name and experiment. This is only possible after the run has successfully finished.

Parameters:
  • experiment_name (str) – The name of the experiment.

  • run_name (str) – The name of the run.

Return type:

Dict[str, Any]

Returns:

Dict of results for example queries before and after fine-tuning.

create_run(experiment_name, run_name, run_config, task, device, cpus, gpus)[source]#

Create a run inside a given experiment.

For optional parameters please visit our documentation (link). :type experiment_name: str :param experiment_name: The name of the experiment. :type run_name: str :param run_name: The name of the run. :type run_config: dict :param run_config: The run configuration. :type device: str :param device: The device to use, either cpu or gpu. :type cpus: int :param cpus: The number of CPUs to use. :type gpus: int :param gpus: The number of GPUs to use. :rtype: dict :return: Created run.