Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kcyganik small changes v03 #185

Merged
merged 5 commits into from
Nov 25, 2023
Merged

Kcyganik small changes v03 #185

merged 5 commits into from
Nov 25, 2023

Conversation

kordc
Copy link
Collaborator

@kordc kordc commented Nov 22, 2023

No description provided.

Runs setup() before every usage of a dataloader taken from lightning's datamodule
closes #164
@kordc kordc requested review from trebacz626 and SebChw November 22, 2023 22:45
@kordc
Copy link
Collaborator Author

kordc commented Nov 22, 2023

The test will fail until SebChw/ART-Templates#33 is merged

Copy link
Owner

@SebChw SebChw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside this setup() issue LGTM.

You solved the issue but at cost of running setup dozen of times.

art/steps.py Outdated
@@ -298,6 +298,10 @@ def validate(self, trainer_kwargs: Dict):
Args:
trainer_kwargs (Dict): Arguments to be passed to the trainer for validating the model.
"""

if "datamodule" not in trainer_kwargs.keys():
Copy link
Owner

@SebChw SebChw Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this solves the issue of setup? I run EvaluateBaselines step from tutorial and setup was run 6 times for 3 baselines. So you run setup to be able to pass train dataloader. Next lightning runs it too.

Copy link
Owner

@SebChw SebChw Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this if inside validate and test seems not necessary. If "datamodule" is not in kwargs it means that a dataloader must be. If dataloader is inside trainer kwargs it means that setup must have been run already.

@@ -395,6 +402,8 @@ def do(self, previous_states: Dict):
Args:
previous_states (Dict): previous states
"""
# Running setup for ml_train with pure train dataloader
self.datamodule.setup(stage=TrainingStage.TRAIN.value)
Copy link
Owner

@SebChw SebChw Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't scale well to new steps. My idea would be like this

add get_trainloader() Function to the base with try catch statement. If it suceeds it just return train_dataloader if it fails it runs datamodule setup function and then returns train_dataloader.

Something like this:

def get_trainloader():
try:
return self.datamodule.get_trainloader()
except :
self.datamodule.setip()
return self.datamodule.get_Trainloader()

But this is just my idea maybe it can be done in other way

@kordc kordc merged commit 1d30f50 into develop Nov 25, 2023
@kordc kordc deleted the kcyganik-small-changes-v03 branch November 25, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants