Getting TypeError: __init__() takes 2 positional arguments but 4 were given #64

Open
opened 2025-11-02 00:02:54 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @minyoungjeong0812 on GitHub (Feb 6, 2024).

Hi, I am following your made-with-ML tutorial and currently at the experiment tracking step. When I ran the following code after specifying a run config based on ML flow callbacks, I am getting Getting TypeError: init() takes 2 positional arguments but 4 were given . Could you please help?

# Dataset
ds = load_data()
train_ds, val_ds = stratify_split(ds, stratify="tag", test_size=test_size)

# Preprocess
preprocessor = CustomPreprocessor()
train_ds = preprocessor.fit_transform(train_ds)
val_ds = preprocessor.transform(val_ds)
train_ds = train_ds.materialize()
val_ds = val_ds.materialize()

# Trainer
trainer = TorchTrainer(
    train_loop_per_worker=train_loop_per_worker,
    train_loop_config=train_loop_config,
    scaling_config=scaling_config,
    run_config=run_config,  # uses RunConfig with MLflow callback
    datasets={"train": train_ds, "val": val_ds},
    dataset_config=dataset_config,
    preprocessor=preprocessor,
)

# Train
results = trainer.fit()
Originally created by @minyoungjeong0812 on GitHub (Feb 6, 2024). Hi, I am following your made-with-ML tutorial and currently at the experiment tracking step. When I ran the following code after specifying a run config based on ML flow callbacks, I am getting **Getting TypeError: __init__() takes 2 positional arguments but 4 were given** . Could you please help? ``` # Dataset ds = load_data() train_ds, val_ds = stratify_split(ds, stratify="tag", test_size=test_size) # Preprocess preprocessor = CustomPreprocessor() train_ds = preprocessor.fit_transform(train_ds) val_ds = preprocessor.transform(val_ds) train_ds = train_ds.materialize() val_ds = val_ds.materialize() # Trainer trainer = TorchTrainer( train_loop_per_worker=train_loop_per_worker, train_loop_config=train_loop_config, scaling_config=scaling_config, run_config=run_config, # uses RunConfig with MLflow callback datasets={"train": train_ds, "val": val_ds}, dataset_config=dataset_config, preprocessor=preprocessor, ) # Train results = trainer.fit() ```
Author
Owner

@bvahdat commented on GitHub (Mar 17, 2024):

Hi @minyoungjeong0812

I ran into the same error which seems to be a bug in ray release 2.7.0 being fixed in 2.7.1:

https://github.com/ray-project/ray/releases/tag/ray-2.7.1

I just upgraded to the version 2.7.1 here and got it properly working after updating the dependencies.

python3 -m pip install -r requirements.txt
@bvahdat commented on GitHub (Mar 17, 2024): Hi @minyoungjeong0812 I ran into the same error which seems to be a bug in ray release `2.7.0` being fixed in `2.7.1`: https://github.com/ray-project/ray/releases/tag/ray-2.7.1 I just upgraded to the version `2.7.1` [here](https://github.com/GokuMohandas/Made-With-ML/blob/main/requirements.txt#L11) and got it properly working after updating the dependencies. ``` python3 -m pip install -r requirements.txt ```
Author
Owner

@NikhilK-crypto commented on GitHub (Jul 31, 2024):

Hi, I'm still experiencing the same issue even after updating Ray to versions 2.7.1 and 2.7.2. I currently have setuptools version 69.5.1 installed.
@minyoungjeong0812 @bvahdat Any assistance would be greatly appreciated. Thank you!

@NikhilK-crypto commented on GitHub (Jul 31, 2024): Hi, I'm still experiencing the same issue even after updating Ray to versions `2.7.1` and `2.7.2`. I currently have setuptools version `69.5.1` installed. @minyoungjeong0812 @bvahdat Any assistance would be greatly appreciated. Thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/Made-With-ML#64