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

CU-8694pey4u: extract cdb load to cls method #446

Merged
merged 7 commits into from
May 30, 2024
Merged

Conversation

tomolopolis
Copy link
Member

to be used in trainer for model pack loading

@tomolopolis
Copy link
Member Author

Task linked: CU-8694pey4u extract cdb load to cls method

Copy link
Collaborator

@mart-r mart-r left a comment

Choose a reason for hiding this comment

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

Just the linting issues, really.

medcat/cat.py Outdated
json_path = model_pack_path if has_jsons else None
logger.info('Loading model pack with %s', 'JSON format' if json_path else 'dill format')
cdb = CDB.load(cdb_path, json_path)
cdb = cls.load_cdb(model_pack_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't really know why the local imports are here (or above in the method at least). My best guess is that at some point this helped avoid circular imports while at the same time provided a guarantee that the classes would be available during model pack loading. But currently, this shouldn't really be an issue since all 4 are imported at the top of the module anyway so there's no reason they wouldn't be available during operation.

So I don't see why we wouldn't just remove the local imports in here.

With that said, that would probably fall outside the scope of this PR.

So I think the easiest solution to the linting issue would be to type-annotate here, e.g cdb: CDB = cls.load_cdb(model_pack_path).

Copy link
Member Author

Choose a reason for hiding this comment

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

done - yeah on above local imports. Agreed prob due to circular imports somewhere... and yes outside of scope of this PR

medcat/cat.py Outdated
meta_cats.append(MetaCAT.load(save_dir_path=meta_path,
config_dict=meta_cat_config_dict))
if load_meta_models:
meta_cats = cls.load_meta_cats(model_pack_path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same overall comment as above.

So I think the easiest solution to the linting issue would be to type-annotate here, e.g meta_cats: List[MetaCAT] = cls.load_meta_cats(model_pack_path).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@tomolopolis tomolopolis force-pushed the load-cdb-cls-method branch 2 times, most recently from 661ab13 to e1a34ab Compare May 30, 2024 09:49
Copy link
Collaborator

@mart-r mart-r left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@tomolopolis tomolopolis merged commit db7259a into master May 30, 2024
8 checks passed
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