Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Nov 6, 2024

Fixes #81

  • Removed InfrahubTransform.init() method that was marked for deprecation (to avoid circular import for InfrahubClient)
  • Change the import_module function to support reloads if changes are noticed as some tests highlighted problems with the current implementation (I think we want to spend some more time on this soon and clean it up some more such as having the sys.path part within a context manager so that we remove the path we just added after importing the module)
  • Change transform to be imported using the .load_class method tied to the repository object instead of using get_transform_class_instance() for consistency between modules (also related to task: Move get_transform_class_instance function to InfrahubPythonTransformConfig method #129)
  • Refactor how we find the generator_definition or transform within each function, the linter was complaining about too many local variables so I modified this to instead use .get_generator_definition() and .get_python_transform(), due to this I also changed the exception that's raised when we fail to find the requested object from KeyError to a new ResourceNotDefinedError.
  • Changed test output related to the refactoring

We should do the same changes for InfrahubCheck but we'll have to get rid of InfrahubCheck.init() first.

@codecov
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 73.07692% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/generator.py 22.22% 7 Missing ⚠️
infrahub_sdk/_importer.py 81.25% 1 Missing and 2 partials ⚠️
infrahub_sdk/schema.py 81.81% 1 Missing and 1 partial ⚠️
infrahub_sdk/transforms.py 50.00% 1 Missing and 1 partial ⚠️
@@             Coverage Diff             @@
##           develop     #128      +/-   ##
===========================================
+ Coverage    65.33%   65.38%   +0.05%     
===========================================
  Files           76       76              
  Lines         6903     6917      +14     
  Branches      1367     1367              
===========================================
+ Hits          4510     4523      +13     
+ Misses        2027     2026       -1     
- Partials       366      368       +2     
Flag Coverage Δ
python-3.10 44.44% <57.69%> (+0.06%) ⬆️
python-3.11 44.44% <57.69%> (+0.06%) ⬆️
python-3.12 44.44% <57.69%> (+0.06%) ⬆️
python-3.9 43.55% <13.46%> (-0.11%) ⬇️
python-filler-3.12 23.79% <15.38%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/cli_commands.py 44.89% <100.00%> (-1.91%) ⬇️
infrahub_sdk/ctl/utils.py 66.17% <100.00%> (+2.20%) ⬆️
infrahub_sdk/exceptions.py 71.60% <100.00%> (+1.47%) ⬆️
infrahub_sdk/schema.py 74.39% <81.81%> (+0.62%) ⬆️
infrahub_sdk/transforms.py 57.37% <50.00%> (-12.63%) ⬇️
infrahub_sdk/_importer.py 73.52% <81.25%> (+41.95%) ⬆️
infrahub_sdk/ctl/generator.py 24.52% <22.22%> (+2.95%) ⬆️

... and 1 file with indirect coverage changes

@ogenstad ogenstad force-pushed the pog-module-imports-IHS-48 branch 4 times, most recently from 0ccd21c to 13c69b3 Compare November 7, 2024 08:25
@ogenstad ogenstad marked this pull request as ready for review November 7, 2024 08:38
@ogenstad ogenstad requested a review from a team November 7, 2024 08:38
@ogenstad ogenstad force-pushed the pog-module-imports-IHS-48 branch from 13c69b3 to c1e37b6 Compare November 7, 2024 09:49
@ogenstad ogenstad force-pushed the pog-module-imports-IHS-48 branch from c1e37b6 to beb14a2 Compare November 7, 2024 11:47
@ogenstad ogenstad merged commit efdcfb7 into develop Nov 7, 2024
12 checks passed
@ogenstad ogenstad deleted the pog-module-imports-IHS-48 branch November 7, 2024 12: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.

bug: importing functions from other modules in repository doens't work consistently

4 participants