-
Notifications
You must be signed in to change notification settings - Fork 1
4523 fix python client to save generate command arguments and reuse them #53
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
Merged
Ash1R
merged 8 commits into
develop
from
4523-Fix-Python-client-to-save-generate-command-arguments-and-reuse-them
Jun 18, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f836f9a
Add caching for all arguments, add names and function-ids arguments
c8efb11
Fix restrictiveness logic to work on all arguments
Ash1R fa7b0fc
Only use cache when indirectly generated
Ash1R e156fa7
initialize cache with generate
Ash1R 69241c0
initialize cache to generate
Ash1R 729f44a
Update toml and config
Ash1R f2df12d
Restore Generating... print message
Ash1R f0a2272
Merge branch 'develop' into 4523-Fix-Python-client-to-save-generate-c…
Ash1R File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| from .server import render_server_function | ||
| from .utils import add_import_to_init, get_auth_headers, init_the_init, print_green, to_func_namespace | ||
| from .variables import generate_variables | ||
| from .config import get_api_key_and_url, get_direct_execute_config | ||
| from .config import get_api_key_and_url, get_direct_execute_config, get_cached_generate_args | ||
|
|
||
| SUPPORTED_FUNCTION_TYPES = { | ||
| "apiFunction", | ||
|
|
@@ -36,7 +36,7 @@ | |
| path:''' | ||
|
|
||
|
|
||
| def get_specs(contexts=Optional[List[str]], no_types: bool = False) -> List: | ||
| def get_specs(contexts: Optional[List[str]] = None, names: Optional[List[str]] = None, function_ids: Optional[List[str]] = None, no_types: bool = False) -> List: | ||
| api_key, api_url = get_api_key_and_url() | ||
| assert api_key | ||
| headers = get_auth_headers(api_key) | ||
|
|
@@ -45,6 +45,12 @@ def get_specs(contexts=Optional[List[str]], no_types: bool = False) -> List: | |
|
|
||
| if contexts: | ||
| params["contexts"] = contexts | ||
|
|
||
| if names: | ||
| params["names"] = names | ||
|
|
||
| if function_ids: | ||
| params["functionIds"] = function_ids | ||
|
Comment on lines
+48
to
+53
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
|
||
| # Add apiFunctionDirectExecute parameter if direct execute is enabled | ||
| if get_direct_execute_config(): | ||
|
|
@@ -264,12 +270,26 @@ def __class_getitem__(cls, item): | |
| ''') | ||
|
|
||
|
|
||
| def generate(contexts: Optional[List[str]] = None, no_types: bool = False) -> None: | ||
| def generate_from_cache() -> None: | ||
| """ | ||
| Generate using cached values after non-explicit call. | ||
| """ | ||
| cached_contexts, cached_names, cached_function_ids, cached_no_types = get_cached_generate_args() | ||
|
|
||
| generate( | ||
| contexts=cached_contexts, | ||
| names=cached_names, | ||
| function_ids=cached_function_ids, | ||
| no_types=cached_no_types | ||
| ) | ||
|
|
||
|
|
||
| def generate(contexts: Optional[List[str]] = None, names: Optional[List[str]] = None, function_ids: Optional[List[str]] = None, no_types: bool = False) -> None: | ||
| generate_msg = f"Generating Poly Python SDK for contexts ${contexts}..." if contexts else "Generating Poly Python SDK..." | ||
| print(generate_msg, end="", flush=True) | ||
| remove_old_library() | ||
|
|
||
| specs = get_specs(no_types=no_types, contexts=contexts) | ||
| specs = get_specs(contexts=contexts, names=names, function_ids=function_ids, no_types=no_types) | ||
| cache_specs(specs) | ||
|
|
||
| limit_ids: List[str] = [] # useful for narrowing down generation to a single function to debug | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice catch. 👍