Skip to content

Conversation

@LucasG0
Copy link
Contributor

@LucasG0 LucasG0 commented Nov 13, 2024

Related PR: opsmill/infrahub#4917

response = await self.client.execute_graphql(query=query.render(), tracker="mutation-branch-create")

if not wait_until_completion:
return BranchData(**response["BranchCreate"]["task"])
Copy link
Contributor Author

@LucasG0 LucasG0 Nov 13, 2024

Choose a reason for hiding this comment

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

  • We cannot return branch object as it has not be created yet, does returning task_id make sense? Downside is that create return signature becomes BranchData | str
  • Currently, background_execution has no effect but is available sdk side, so this is somehow a small breaking change even though I do not expect of this parameter to be used

Copy link
Contributor

Choose a reason for hiding this comment

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

  • We cannot return branch object as it has not be created yet, does returning task_id make sense? Downside is that create return signature becomes BranchData | str

That's unfortunate. But for now I think we should go with BranchData | str I don't remember if that works on Python 3.9 or if we have to do a Union[BranchData, str]. What we can do is to use an @overload decorator which we use in a few other places. We can use that to indicate the returned data type depending on the input params used.

@LucasG0 LucasG0 force-pushed the lgu-add-wait-until-completion branch from a671c0d to da85da4 Compare November 13, 2024 11:25
description: str = "",
background_execution: bool = False,
) -> BranchData:
wait_until_completion: bool = False,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we add this parameter for other branch methods (merge, ...)?

@LucasG0 LucasG0 force-pushed the lgu-add-wait-until-completion branch 2 times, most recently from ede1137 to 700985d Compare November 13, 2024 11:37
@LucasG0 LucasG0 requested a review from a team November 13, 2024 11:43
@LucasG0 LucasG0 force-pushed the lgu-add-wait-until-completion branch 3 times, most recently from 8d7a9ac to bb63b82 Compare November 14, 2024 11:08
query = Mutation(mutation="BranchCreate", input_data=input_data, query=MUTATION_QUERY_DATA)
response = await self.client.execute_graphql(query=query.render(), tracker="mutation-branch-create")

# Make sure server version is recent enough to support background execution, as previously
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if this is so useful because if the server doesn't support wait_until_completion it will blow up when you execute the query 2 lines up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, let's use deprecated background_execution as query input field so query does not break, and we will switch to wait_until_completion the day background_execution is completely removed from the graphql query.

@LucasG0 LucasG0 force-pushed the lgu-add-wait-until-completion branch from bb63b82 to e95caeb Compare November 14, 2024 13:10
@codecov
Copy link

codecov bot commented Nov 14, 2024

Codecov Report

Attention: Patch coverage is 45.00000% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/branch.py 45.00% 7 Missing and 4 partials ⚠️
@@             Coverage Diff             @@
##           develop     #142      +/-   ##
===========================================
- Coverage    65.40%   65.32%   -0.08%     
===========================================
  Files           76       76              
  Lines         6923     6942      +19     
  Branches      1367     1375       +8     
===========================================
+ Hits          4528     4535       +7     
- Misses        2026     2037      +11     
- Partials       369      370       +1     
Flag Coverage Δ
python-3.10 44.31% <10.00%> (-0.10%) ⬇️
python-3.11 ?
python-3.12 ?
python-3.9 ?
python-filler-3.12 23.85% <35.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
infrahub_sdk/branch.py 45.71% <45.00%> (-1.40%) ⬇️

... and 3 files with indirect coverage changes

@LucasG0 LucasG0 force-pushed the lgu-add-wait-until-completion branch from e95caeb to 9105436 Compare November 14, 2024 13:14
@LucasG0 LucasG0 merged commit 761a1c7 into develop Nov 14, 2024
12 checks passed
@LucasG0 LucasG0 deleted the lgu-add-wait-until-completion branch November 14, 2024 13:32
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.

4 participants