# \<class 'wandb.sdk.wandb\_config.Config'\> object has no attribute 'copy'

**URL:** <https://community.wandb.ai/t/class-wandb-sdk-wandb-config-config-object-has-no-attribute-copy/5927>\
**Category:** W&B Help\
**Tags:** sweeps, wandb\
**Created:** [February 19, 2024, 11:54am UTC](https://community.wandb.ai/t/class-wandb-sdk-wandb-config-config-object-has-no-attribute-copy/5927 "2024-02-19T11:54:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ht99](https://avatars.discourse-cdn.com/v4/letter/h/ee59a6/32.png) [@ht99](https://community.wandb.ai/u/ht99)\
**Post date:** [February 19, 2024, 11:54am UTC](https://community.wandb.ai/t/class-wandb-sdk-wandb-config-config-object-has-no-attribute-copy/5927/1 "2024-02-19T11:54:43Z")

</div>

I am running a hyperparameter sweep, but the config dict doesn’t seem to have the usual dict attribute ‘copy’. This is a problem because in the xgboost package, `xgb.train()` requires the parameters to be copied when boosting. I’m unable to train xgboost in a sweep without xgb being able to .copy() the config. Here is a quick demo:

```auto
sweep_config = {
    'method': 'random',
    'parameters': {
        'gamma': {
            'values': [0.1, 0.2, 0.3]
        },
        'lambda': { 
            'values': [0.4, 0.5, 0.6, 0.7, 0.8]
        },
        'learning_rate': {
            'values': [0.001, 0.01, 0.05, 0.1]
        },
        'objective': {
            'value': 'multi:softprob',
        },
        'num_class': {
            'value': 3
        },
    }
}

```

```auto
def train(config=None):
    with wandb.init(
    ):
        config = wandb.config
        config.copy()

```

```auto
sweep_id = wandb.sweep(sweep_config, project="my_project_name")
wandb.agent(sweep_id, train, count=10)

```

The error message is:

```auto
Traceback (most recent call last):
  File "/path/to/miniconda3/envs/myenv_py311/lib/python3.11/site-packages/wandb/sdk/wandb_config.py", line 162, in __getattr__
    return self. __getitem__ (key)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/miniconda3/envs/myenv_py311/lib/python3.11/site-packages/wandb/sdk/wandb_config.py", line 130, in __getitem__
    return self._items[key]
           ~~~~~~~~~~~ ^^^^^
KeyError: 'copy'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/folders/_t/gnglhcjx7bq497x344n42txc0000gq/T/ipykernel_5206/2730897414.py", line 5, in train
    config.copy()
    ^^^^^^^^^^^
  File "/path/to/miniconda3/envs/myenv_py311/lib/python3.11/site-packages/wandb/sdk/wandb_config.py", line 164, in __getattr__
    raise AttributeError(
AttributeError: <class 'wandb.sdk.wandb_config.Config'> object has no attribute 'copy'

```

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [February 23, 2024, 5:21am UTC](https://community.wandb.ai/t/class-wandb-sdk-wandb-config-config-object-has-no-attribute-copy/5927/2 "2024-02-23T05:21:44Z")

</div>

hey @ht99 - your observation is correct; we don’t support using .`copy()` with `wandb.config` since this is not a standard python dictionary but rather a `wandb.sdk.wandb_config.Config` object. I recommend changing the `config.copy()` line to `config.as_dict().copy()` if you’d like to do dictionary operations on `wandb.config` going forward

---

<div class="post-metadata">

**Author:** ![ht99](https://avatars.discourse-cdn.com/v4/letter/h/ee59a6/32.png) [@ht99](https://community.wandb.ai/u/ht99)\
**Post date:** [February 23, 2024, 12:52pm UTC](https://community.wandb.ai/t/class-wandb-sdk-wandb-config-config-object-has-no-attribute-copy/5927/3 "2024-02-23T12:52:12Z")

</div>

Awesome thanks so much for clarifying, I appreciate it!
