-
Notifications
You must be signed in to change notification settings - Fork 102
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
Conversation
…or model pack loading
Task linked: CU-8694pey4u extract cdb load to cls method |
There was a problem hiding this 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) |
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
661ab13
to
e1a34ab
Compare
e1a34ab
to
bc78a53
Compare
There was a problem hiding this 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.
to be used in trainer for model pack loading