From 9129e5a400b6fc053993a17ab606e68fe680fc1f Mon Sep 17 00:00:00 2001 From: Zhao Changmin Date: Wed, 21 Sep 2022 21:11:49 +0800 Subject: [PATCH] Orca: `copy` name duplicated (#5886) * Orca: `copy` name duplicated --- .../orca/src/bigdl/orca/automl/model/base_keras_model.py | 4 ++-- .../src/bigdl/orca/automl/model/base_pytorch_model.py | 4 ++-- python/orca/src/bigdl/orca/learn/mxnet/mxnet_runner.py | 4 ++-- .../orca/src/bigdl/orca/learn/pytorch/callbacks/wandb.py | 4 ++-- .../bigdl/orca/learn/pytorch/pytorch_pyspark_estimator.py | 4 ++-- .../bigdl/orca/learn/pytorch/pytorch_pyspark_worker.py | 4 ++-- .../src/bigdl/orca/learn/pytorch/pytorch_ray_estimator.py | 4 ++-- .../src/bigdl/orca/learn/pytorch/pytorch_ray_worker.py | 4 ++-- python/orca/src/bigdl/orca/learn/pytorch/torch_runner.py | 8 ++++---- python/orca/src/bigdl/orca/learn/tf2/spark_runner.py | 8 ++++---- python/orca/src/bigdl/orca/learn/tf2/tf_runner.py | 8 ++++---- 11 files changed, 28 insertions(+), 28 deletions(-) diff --git a/python/orca/src/bigdl/orca/automl/model/base_keras_model.py b/python/orca/src/bigdl/orca/automl/model/base_keras_model.py index a668fb2d3ed..d49711ef06d 100644 --- a/python/orca/src/bigdl/orca/automl/model/base_keras_model.py +++ b/python/orca/src/bigdl/orca/automl/model/base_keras_model.py @@ -17,7 +17,7 @@ import numpy as np from bigdl.orca.automl.metrics import Evaluator import pickle -from copy import copy +import copy import tensorflow as tf from tensorflow.keras import backend as K import types @@ -88,7 +88,7 @@ def update_config(): update_config() self.build(config) else: - tmp_config = copy(self.config) + tmp_config = copy.copy(self.config) tmp_config.update(config) self._check_config(**tmp_config) self.config.update(config) diff --git a/python/orca/src/bigdl/orca/automl/model/base_pytorch_model.py b/python/orca/src/bigdl/orca/automl/model/base_pytorch_model.py index 75fc88791d5..1111fcc9d75 100644 --- a/python/orca/src/bigdl/orca/automl/model/base_pytorch_model.py +++ b/python/orca/src/bigdl/orca/automl/model/base_pytorch_model.py @@ -22,7 +22,7 @@ import pandas as pd import tempfile import os -from copy import copy +import copy from bigdl.orca.automl.model.abstract import BaseModel, ModelBuilder from bigdl.orca.automl.metrics import Evaluator @@ -144,7 +144,7 @@ def update_config(): update_config() self.build(config) else: - tmp_config = copy(self.config) + tmp_config = copy.copy(self.config) tmp_config.update(config) self._check_config(**tmp_config) self.config.update(config) diff --git a/python/orca/src/bigdl/orca/learn/mxnet/mxnet_runner.py b/python/orca/src/bigdl/orca/learn/mxnet/mxnet_runner.py index de80cb20069..233f24ca233 100644 --- a/python/orca/src/bigdl/orca/learn/mxnet/mxnet_runner.py +++ b/python/orca/src/bigdl/orca/learn/mxnet/mxnet_runner.py @@ -21,7 +21,7 @@ import ray._private.services import mxnet as mx from mxnet import gluon -from copy import copy +import copy from bigdl.orca.ray.utils import to_list from bigdl.dllib.utils.log4Error import * @@ -84,7 +84,7 @@ def train(self, train_data, epochs=1, batch_size=32, """Train the model and update the model parameters.""" stats = dict() if self.is_worker: - config = copy(self.config) + config = copy.copy(self.config) if "batch_size" not in config: config["batch_size"] = batch_size diff --git a/python/orca/src/bigdl/orca/learn/pytorch/callbacks/wandb.py b/python/orca/src/bigdl/orca/learn/pytorch/callbacks/wandb.py index 1af560a12a0..c137e5c1ab6 100644 --- a/python/orca/src/bigdl/orca/learn/pytorch/callbacks/wandb.py +++ b/python/orca/src/bigdl/orca/learn/pytorch/callbacks/wandb.py @@ -15,7 +15,7 @@ # from bigdl.orca.learn.pytorch.callbacks import Callback from bigdl.dllib.utils.log4Error import invalidInputError -from copy import copy +import copy try: import wandb @@ -86,7 +86,7 @@ def on_train_begin(self): else: config = {} if self.log_config: - trainer_config = copy(self.trainer.config) + trainer_config = copy.copy(self.trainer.config) config.update(trainer_config) if is_rank_zero: diff --git a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_estimator.py b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_estimator.py index c1eec25e52f..b7bc604ee83 100644 --- a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_estimator.py +++ b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_estimator.py @@ -19,7 +19,7 @@ import numbers import torch import numpy as np -from copy import copy +import copy from bigdl.orca.learn.pytorch.training_operator import TrainingOperator from bigdl.orca.learn.pytorch.pytorch_pyspark_worker import PytorchPysparkWorker @@ -145,7 +145,7 @@ def __init__( training_operator_cls=training_operator_cls, scheduler_step_freq=scheduler_step_freq, use_tqdm=use_tqdm, - config=copy(self.config), + config=copy.copy(self.config), metrics=metrics, size=self.num_workers, cores_per_worker=self.cores_per_worker, diff --git a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_worker.py b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_worker.py index f4e0713ed8e..fd079bfc080 100644 --- a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_worker.py +++ b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_pyspark_worker.py @@ -37,7 +37,7 @@ from bigdl.orca.learn.utils import save_pkl import os import tempfile -from copy import copy +import copy from pyspark import BarrierTaskContext, TaskContext from bigdl.orca.learn.utils import save_pkl, duplicate_stdout_stderr_to_file, get_rank @@ -161,7 +161,7 @@ def validate(self, data_creator, batch_size=32, num_steps=None, profile=False, def predict(self, data_creator, batch_size=32, profile=False): """Evaluates the model on the validation data set.""" - config = copy(self.config) + config = copy.copy(self.config) self._toggle_profiling(profile=profile) partition = data_creator(config, batch_size) diff --git a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_estimator.py b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_estimator.py index 2a83ab8d7d9..fa643e06c11 100644 --- a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_estimator.py +++ b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_estimator.py @@ -20,7 +20,7 @@ import numbers import torch import numpy as np -from copy import copy +import copy from bigdl.orca.data.ray_xshards import RayXShards from bigdl.orca.learn.pytorch.training_operator import TrainingOperator @@ -149,7 +149,7 @@ def __init__( self.initialization_hook = initialization_hook self.config = {} if config is None else config - worker_config = copy(self.config) + worker_config = copy.copy(self.config) params = dict( model_creator=self.model_creator, optimizer_creator=self.optimizer_creator, diff --git a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_worker.py b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_worker.py index 2d3133cf684..60095908b8a 100644 --- a/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_worker.py +++ b/python/orca/src/bigdl/orca/learn/pytorch/pytorch_ray_worker.py @@ -29,7 +29,7 @@ # limitations under the License. import ray -from copy import copy +import copy from bigdl.orca.learn.pytorch.utils import find_free_port from bigdl.orca.learn.pytorch.torch_runner import TorchRunner import torch.nn as nn @@ -119,7 +119,7 @@ def setup_components_horovod(self): def predict(self, data_creator, batch_size=32, profile=False): """Evaluates the model on the validation data set.""" - config = copy(self.config) + config = copy.copy(self.config) self._toggle_profiling(profile=profile) shards_ref = data_creator(config, batch_size) diff --git a/python/orca/src/bigdl/orca/learn/pytorch/torch_runner.py b/python/orca/src/bigdl/orca/learn/pytorch/torch_runner.py index 0b0d60a80c9..5ed8f0039d8 100644 --- a/python/orca/src/bigdl/orca/learn/pytorch/torch_runner.py +++ b/python/orca/src/bigdl/orca/learn/pytorch/torch_runner.py @@ -36,7 +36,7 @@ import io import itertools import os -from copy import copy +import copy import tempfile import torch import torch.nn as nn @@ -256,7 +256,7 @@ def should_wrap_dataloader(loader): def train_epochs(self, data_creator, epochs=1, batch_size=32, profile=False, info=None, wrap_dataloader=None, callbacks=None, validation_data_creator=None): - config = copy(self.config) + config = copy.copy(self.config) if OrcaContext.serialize_data_creator: with FileLock( os.path.join(tempfile.gettempdir(), ".orcadata.lock")): @@ -383,7 +383,7 @@ def train_epoch(self, def validate(self, data_creator, batch_size=32, num_steps=None, profile=False, info=None, wrap_dataloader=None): """Evaluates the model on the validation data set.""" - config = copy(self.config) + config = copy.copy(self.config) info = info or {} self._toggle_profiling(profile=profile) @@ -412,7 +412,7 @@ def validate(self, data_creator, batch_size=32, num_steps=None, profile=False, def predict(self, partition, batch_size=32, profile=False): """Evaluates the model on the validation data set.""" - config = copy(self.config) + config = copy.copy(self.config) self._toggle_profiling(profile=profile) params = {"batch_size": batch_size, "shuffle": False} diff --git a/python/orca/src/bigdl/orca/learn/tf2/spark_runner.py b/python/orca/src/bigdl/orca/learn/tf2/spark_runner.py index fff0c0c05ef..4e495cdf2d3 100644 --- a/python/orca/src/bigdl/orca/learn/tf2/spark_runner.py +++ b/python/orca/src/bigdl/orca/learn/tf2/spark_runner.py @@ -18,7 +18,7 @@ import os import tempfile import shutil -from copy import copy +import copy import tensorflow as tf @@ -319,7 +319,7 @@ def step(self, data_creator, epochs=1, batch_size=32, verbose=1, """ Get model training results and new model. """ - config = copy(self.config) + config = copy.copy(self.config) if data_config is not None: config.update(data_config) config["batch_size"] = batch_size @@ -373,7 +373,7 @@ def validate(self, data_creator, batch_size=32, verbose=1, sample_weight=None, """ Evaluates the model on the validation data set. """ - config = copy(self.config) + config = copy.copy(self.config) if data_config is not None: config.update(data_config) config["batch_size"] = batch_size @@ -431,7 +431,7 @@ def validate(self, data_creator, batch_size=32, verbose=1, sample_weight=None, return [] def predict(self, data_creator, batch_size, verbose, steps, callbacks, data_config): - config = copy(self.config) + config = copy.copy(self.config) if data_config is not None: config.update(data_config) diff --git a/python/orca/src/bigdl/orca/learn/tf2/tf_runner.py b/python/orca/src/bigdl/orca/learn/tf2/tf_runner.py index a9258ed2537..de117a0f727 100644 --- a/python/orca/src/bigdl/orca/learn/tf2/tf_runner.py +++ b/python/orca/src/bigdl/orca/learn/tf2/tf_runner.py @@ -35,7 +35,7 @@ import shutil import tempfile import subprocess -from copy import copy +import copy import ray import numpy as np @@ -335,7 +335,7 @@ def step(self, data_creator, epochs=1, batch_size=32, verbose=1, steps_per_epoch=None, validation_steps=None, validation_freq=1, data_config=None): """Runs a training epoch and updates the model parameters.""" - config = copy(self.config) + config = copy.copy(self.config) if data_config is not None: config.update(data_config) config["batch_size"] = batch_size @@ -385,7 +385,7 @@ def step(self, data_creator, epochs=1, batch_size=32, verbose=1, def validate(self, data_creator, batch_size=32, verbose=1, sample_weight=None, steps=None, callbacks=None, data_config=None): """Evaluates the model on the validation data set.""" - config = copy(self.config) + config = copy.copy(self.config) if data_config is not None: config.update(data_config) config["batch_size"] = batch_size @@ -433,7 +433,7 @@ def validate(self, data_creator, batch_size=32, verbose=1, sample_weight=None, return [stats] def predict(self, data_creator, batch_size, verbose, steps, callbacks, data_config): - config = copy(self.config) + config = copy.copy(self.config) if data_config is not None: config.update(data_config)