Skip to content

Conversation

@ogenstad
Copy link
Contributor

@ogenstad ogenstad commented Mar 20, 2025

The goal of this PR is primarily for use within computed attributes, currently for the Jinja2 template based computed attributes we are constantly refreshing the schema of the SDK for each attribute. This is because we have no way of knowing if the schema in the client is up to date or if a branch we'd previously cashed has updates. With this in place we can send in the current hash stored in the registry to the schema.all method and only call the /api/schema endpoint if any updates have actually been made.

As a follow up to this PR I'm thinking that we should mark the public schema.fetch() method as deprecated. I don't think anyone uses it and instead use schema.get() or schema.all().

Fixes #152.

@codecov
Copy link

codecov bot commented Mar 20, 2025

Codecov Report

Attention: Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/schema/__init__.py 93.75% 2 Missing ⚠️
@@             Coverage Diff             @@
##           develop     #310      +/-   ##
===========================================
+ Coverage    70.64%   71.32%   +0.67%     
===========================================
  Files           81       87       +6     
  Lines         7499     7871     +372     
  Branches      1457     1517      +60     
===========================================
+ Hits          5298     5614     +316     
- Misses        1818     1865      +47     
- Partials       383      392       +9     
Flag Coverage Δ
integration-tests 22.80% <22.22%> (+0.14%) ⬆️
python-3.10 45.45% <77.77%> (-0.11%) ⬇️
python-3.11 45.48% <77.77%> (-0.09%) ⬇️
python-3.12 45.48% <77.77%> (-0.09%) ⬇️
python-3.13 45.45% <77.77%> (?)
python-3.9 44.35% <77.77%> (-0.06%) ⬇️
python-filler-3.12 24.66% <19.44%> (+0.60%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/schema/main.py 84.04% <100.00%> (+0.57%) ⬆️
infrahub_sdk/schema/__init__.py 70.06% <93.75%> (+2.05%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ogenstad ogenstad requested a review from a team March 20, 2025 09:54
Copy link
Contributor

@dgarros dgarros left a comment

Choose a reason for hiding this comment

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

LGTM
Not sure about marking fetch as deprecated ... it's probably not used extensively but it could be useful.

@ogenstad ogenstad merged commit 94d6199 into develop Mar 20, 2025
17 checks passed
@ogenstad ogenstad deleted the pog-sdk-selective-schema-hash-update-IHS-69 branch March 20, 2025 15:00
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