Skip to content

Conversation

@jveitchmichaelis
Copy link
Collaborator

@jveitchmichaelis jveitchmichaelis commented Apr 17, 2025

For review - there are some outstanding todos in the issue thread, mainly around documentation and whether we want to include some additional usage scenarios at this point (like CLI, SLURM tests, etc).

Suggest filtering by this commit first c664dbc

Addresses #847

Copy link
Contributor

@henrykironde henrykironde left a comment

Choose a reason for hiding this comment

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

Thanks @jveitchmichaelis, the changes seem fine, I have made some suggestions where I feel there may be some issues. Let me know what you think.

Args:
num_classes (int): number of classes in the model
config_file (str): path to deepforest config file
num_classes (int): number of classes in the model
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the order of the args the same as defined in the function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I think for now that's a good idea.

Long term (2.0?), I think we could encourage users to go via the config route and provide fewer selected keyword arguments here. I'll have a look at how other projects have done this because there's probably a balance.

if config is None:
config = utilities.load_config("config", overrides=config_args)
elif 'config_file' in config:
# This is from the hub
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this comment here.

Copy link
Collaborator Author

@jveitchmichaelis jveitchmichaelis Apr 20, 2025

Choose a reason for hiding this comment

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

Yeah mostly included for awareness - this condition can be deprecated at some point, when we revise the hub model. Possibly we want to update the checkpoint alongside this?

self.config = config

# If num classes is specified, overwrite config
if not num_classes == 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

I expected that if num_classes is set to 1 by default, that value would be used unless explicitly overridden. Since Hydra manages config composition and sanity checks, we shouldn't need to add extra if conditions—either the default is used or an override is applied automatically.

Copy link
Collaborator Author

@jveitchmichaelis jveitchmichaelis Apr 24, 2025

Choose a reason for hiding this comment

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

The condition is from the existing code to declare it's deprecated, so I assumed we'd want to keep it (if we're also keeping the same constructor signature)?

@pytest.mark.xfail
def test_custom_config_file_path(ROOT, tmpdir):
m = main.deepforest(
config_file='{}/deepforest_config.yml'.format(os.path.dirname(ROOT)))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should be able to swap to the new config file.

cfg = compose(config_name=config_name)
cfg.merge_with(overrides)
else:
if isinstance(overrides, str):
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens to the list type if parsed to the function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reference example for compose uses a list of key=value strings as if you've passed in things from the command line.

https://hydra.cc/docs/advanced/compose_api/

So depends how we expect users to override the config and what "user experiences" we imagine. Maybe we can discuss this in the issue?

@jveitchmichaelis
Copy link
Collaborator Author

jveitchmichaelis commented Apr 20, 2025

Looks good, I'll fix up the tests this week and think about adding some new documentation with usage examples. Some of the issues you raised might need a bit more discussion.

@jveitchmichaelis
Copy link
Collaborator Author

jveitchmichaelis commented May 5, 2025

@henrykironde once the tests pass, check the revisions out and if you're happy, this can all be squashed.

@jveitchmichaelis jveitchmichaelis changed the title WIP: Hydra integration Hydra integration May 5, 2025
Copy link
Contributor

@henrykironde henrykironde left a comment

Choose a reason for hiding this comment

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

This looks good overall. We should add some more tests for load_config with the expected arguments types in a follow-up. For now, I’ll go ahead and merge this since the PR is already quite large.

@henrykironde henrykironde merged commit 4fb5b9d into weecology:main May 6, 2025
4 checks passed
@jveitchmichaelis jveitchmichaelis deleted the hydra-integration branch May 6, 2025 13:28
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.

2 participants