From e535e6a80eca1b978382cbbb87360fe2e42cdb75 Mon Sep 17 00:00:00 2001 From: Louis Milliken <58855099+LMMilliken@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:23:37 +0100 Subject: [PATCH] refactor: deprecate cpu (#631) * refactor: deprecate cpu * chore: update changelog * refactor: removed CPU constant * refactor: remove noteboook_login function * removed mentions of 'cpu' and 'notebook_login' --- CHANGELOG.md | 4 ++++ finetuner/__init__.py | 13 ------------- finetuner/constants.py | 1 - finetuner/experiment.py | 8 -------- finetuner/finetuner.py | 4 ---- tests/unit/test_experiment.py | 1 - 6 files changed, 4 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3f989842..832f94cbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Removed +- Remove `cpu` parameter from `create_run` function. ([#631](https://github.com/jina-ai/finetuner/pull/631)) + +- Remove `notebook_login` function. ([#631](https://github.com/jina-ai/finetuner/pull/631)) + ### Changed - Adjust Finetuner based on API changes for Jina AI Cloud. ([#637](https://github.com/jina-ai/finetuner/pull/637)) diff --git a/finetuner/__init__.py b/finetuner/__init__.py index 8b3fd99d9..25dfca8a4 100644 --- a/finetuner/__init__.py +++ b/finetuner/__init__.py @@ -48,15 +48,6 @@ def login(force: bool = False, interactive: Optional[bool] = None): ft.login(force=force, interactive=interactive) -def notebook_login(force: bool = False): - warnings.warn( - message='Function `notebook_login` will be deprecated from Finetuner 0.7.0,' - 'please use `login(interactive=True)` instead.', - category=DeprecationWarning, - ) - ft.login(force=force, interactive=True) - - def list_callbacks() -> Dict[str, callback.CallbackStubType]: """List available callbacks.""" return { @@ -132,7 +123,6 @@ def fit( scheduler_step: str = 'batch', freeze: bool = False, output_dim: Optional[int] = None, - cpu: bool = True, device: str = 'cuda', num_workers: int = 4, to_onnx: bool = False, @@ -196,8 +186,6 @@ def fit( :param freeze: If set to `True`, will freeze all layers except the last one. :param output_dim: The expected output dimension as `int`. If set, will attach a projection head. - :param cpu: Whether to use the CPU. If set to `False` a GPU will be used. - Will be deprecated from 0.7.0. :param device: Whether to use the CPU, if set to `cuda`, a Nvidia GPU will be used. otherwise use `cpu` to run a cpu job. :param num_workers: Number of CPU workers. If `cpu: False` this is the number of @@ -240,7 +228,6 @@ def fit( scheduler_step=scheduler_step, freeze=freeze, output_dim=output_dim, - cpu=cpu, device=device, num_workers=num_workers, to_onnx=to_onnx, diff --git a/finetuner/constants.py b/finetuner/constants.py index 6e733f2e7..e685308bf 100644 --- a/finetuner/constants.py +++ b/finetuner/constants.py @@ -13,7 +13,6 @@ CONFIG = 'config' FINETUNER_VERSION = 'finetuner_version' DEVICE = 'device' -CPU = 'cpu' CPUS = 'cpus' GPUS = 'gpus' NUM_WORKERS = 'num_workers' diff --git a/finetuner/experiment.py b/finetuner/experiment.py index 51123d3b6..44e2bd8b0 100644 --- a/finetuner/experiment.py +++ b/finetuner/experiment.py @@ -1,4 +1,3 @@ -import warnings from dataclasses import fields from typing import Any, Dict, List, Optional, TextIO, Union @@ -11,7 +10,6 @@ BATCH_SIZE, CALLBACKS, CONFIG, - CPU, CREATED_AT, DESCRIPTION, DEVICE, @@ -186,12 +184,6 @@ def create_run( device = kwargs.get(DEVICE, 'cuda') if device == 'cuda': device = 'gpu' - if kwargs.get(CPU, True): - warnings.warn( - message='Parameter `cpu` will be deprecated from Finetuner 0.7.0,' - 'please use `device="cpu" or `device="cuda" instead.`', - category=DeprecationWarning, - ) num_workers = kwargs.get(NUM_WORKERS, 4) run = self._client.create_run( diff --git a/finetuner/finetuner.py b/finetuner/finetuner.py index 81d1af40d..eae2b006c 100644 --- a/finetuner/finetuner.py +++ b/finetuner/finetuner.py @@ -25,8 +25,6 @@ def login(self, force: bool = False, interactive: Optional[bool] = None): and create a default experiment. :param force: If set to true, overwrite token and re-login. - :param interactive: If set to true, will use `notebook_login` as interactive - mode. Note: Calling `login` is necessary for using finetuner. """ @@ -164,7 +162,6 @@ def create_run( scheduler_step: str = 'batch', freeze: bool = False, output_dim: Optional[int] = None, - cpu: bool = True, device: str = 'cuda', num_workers: int = 4, to_onnx: bool = False, @@ -203,7 +200,6 @@ def create_run( scheduler_step=scheduler_step, freeze=freeze, output_dim=output_dim, - cpu=cpu, device=device, num_workers=num_workers, to_onnx=to_onnx, diff --git a/tests/unit/test_experiment.py b/tests/unit/test_experiment.py index 23572c298..ad2964ae3 100644 --- a/tests/unit/test_experiment.py +++ b/tests/unit/test_experiment.py @@ -149,7 +149,6 @@ def test_create_run_config(): freeze=False, output_dim=None, multi_modal=False, - cpu=False, device='cuda', ) assert config == expected_config