Skip to content

Commit

Permalink
Orca: copy name duplicated (#5886)
Browse files Browse the repository at this point in the history
* Orca: `copy` name duplicated
  • Loading branch information
leonardozcm authored Sep 21, 2022
1 parent c24e011 commit 9129e5a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions python/orca/src/bigdl/orca/automl/model/base_keras_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions python/orca/src/bigdl/orca/automl/model/base_pytorch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions python/orca/src/bigdl/orca/learn/mxnet/mxnet_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions python/orca/src/bigdl/orca/learn/pytorch/callbacks/wandb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions python/orca/src/bigdl/orca/learn/pytorch/torch_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")):
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions python/orca/src/bigdl/orca/learn/tf2/spark_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import tempfile
import shutil
from copy import copy
import copy

import tensorflow as tf

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions python/orca/src/bigdl/orca/learn/tf2/tf_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import shutil
import tempfile
import subprocess
from copy import copy
import copy

import ray
import numpy as np
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9129e5a

Please sign in to comment.