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

Simplify external projects, unify plugin API #2146

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jkulhanek
Copy link
Contributor

This PR implements the following:

  • Moves the AnnotatedDataParserConfig out of VanillaDataManagerConfig which simplifies custom methods as there won't be circular imports when DataParser is in the same file as the Model.
  • Moves Annotated method configs out of nerfstudio.config.method_configs and users can extend existing configuration files in external methods.
  • Unifies the discover_methods, discover_dataparsers API.

@jkulhanek jkulhanek requested a review from brentyi June 29, 2023 14:08
the same as the vanilla union, but results in shorter subcommand names."""


def fix_method_dataparser_type(method_config: TrainerConfig):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brentyi , can you please take a closer look at this function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense but feels scary to me, is there no way to keep the parsers annotated as AnnotatedDataParserUnion? Is the issue with circular imports? Would breaking this file up into smaller files (like one where the dataparser union is defined and one where the method union is defined) help?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think having the AnnotatedDataParserUnion in the DataManagerConfig is a bad design which leads to circular imports when you want to define the DataParser and something else (trainerconfig) in the same file. I agree that redefining the types here is not the safest. I think it would be preferable if there was a way to instruct tyro to do it instead: replace base types with the annotated unions? What do you think? If you like this solution I can try to implement it in tyro.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry for missing your reply, I had accidentally left my comment twice and assumed you hadn't replied yet because I was looking at the other one...

I think it would be preferable if there was a way to instruct tyro to do it instead: replace base types with the annotated unions

Yeah, this makes sense. There's an unfinished PR that would enable this here: brentyi/tyro#30

If you're willing to make a PR to tyro making this kind of thing possible — either building on my PR or starting from scratch — that'd of course be awesome, but I don't have a good sense of how long something like that would take (or how long getting ramped up on the tyro codebase would take).

If it's too much effort just splitting things like the DataParser + trainerconfig that you described into separate files seems like an unideal but workable short-term solution.

@jkulhanek jkulhanek force-pushed the jkulhanek/unify-plugin-registry branch 3 times, most recently from 20a30cb to 97567d7 Compare June 29, 2023 14:51
@jkulhanek jkulhanek force-pushed the jkulhanek/unify-plugin-registry branch from 97567d7 to 68adfb6 Compare June 29, 2023 14:54
from nerfstudio.plugins.registry import discover_dataparsers, discover_methods


def merge_methods(methods, method_descriptions, new_methods, new_descriptions, overwrite=True):
Copy link
Collaborator

Choose a reason for hiding this comment

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

while we're making changes, can we add annotations here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

nerfstudio/configs/annotated_types.py Show resolved Hide resolved
the same as the vanilla union, but results in shorter subcommand names."""


def fix_method_dataparser_type(method_config: TrainerConfig):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes sense but feels scary to me, is there no way to keep the parsers annotated as AnnotatedDataParserUnion? Is the issue with circular imports? Would breaking this file up into smaller files (like one where the dataparser union is defined and one where the method union is defined) help?

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