Skip to content

Improve client script formatting (black linter formatting) and added logger once runner start#705

Merged
luv-bansal merged 14 commits intomasterfrom
back-linter-code-snippet
Jul 17, 2025
Merged

Improve client script formatting (black linter formatting) and added logger once runner start#705
luv-bansal merged 14 commits intomasterfrom
back-linter-code-snippet

Conversation

@luv-bansal
Copy link
Copy Markdown
Contributor

@luv-bansal luv-bansal commented Jul 17, 2025

Pull Request Overview

This PR refactors the client code generator to use f-strings, improves the layout of generated snippets, and adds a startup log in the runner server.

  • Migrates %-style formatting to inline f-strings and standardizes string quoting.
  • Reorganizes generated method and model sections into clearer multi-line blocks.
  • Logs a message when the runner starts in server.py.

@luv-bansal luv-bansal requested a review from Copilot July 17, 2025 09:19

This comment was marked as outdated.

@luv-bansal luv-bansal requested a review from Copilot July 17, 2025 11:09

This comment was marked as outdated.

@luv-bansal luv-bansal requested a review from Copilot July 17, 2025 11:51

This comment was marked as outdated.

@luv-bansal luv-bansal requested a review from Copilot July 17, 2025 11:54

This comment was marked as outdated.

This comment was marked as outdated.

@luv-bansal luv-bansal changed the title Back linter code snippet Improve client script formatting (black linter formatting) and added logger once runner start Jul 17, 2025
@luv-bansal luv-bansal requested a review from Copilot July 17, 2025 12:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the client code generator to use f-strings, improves the layout of generated snippets, and adds a startup log in the runner server.

  • Migrates %-style formatting to inline f-strings and standardizes string quoting.
  • Reorganizes generated method and model sections into clearer multi-line blocks.
  • Logs a message when the runner starts in server.py.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
clarifai/runners/utils/code_script.py Switched templates to f-strings, streamlined parameter blocks.
clarifai/runners/server.py Inserted a logger.info call after runner startup.
Comments suppressed due to low confidence (2)

clarifai/runners/utils/code_script.py:47

  • [nitpick] The triple-quoted f-string with nested braces and manual escaping can be fragile and hard to read. Consider using textwrap.dedent to clean up indentation and externalize nested dicts or format them programmatically to avoid double-brace escaping.
        _CLIENT_TEMPLATE = f"""

clarifai/runners/server.py:136

  • Ensure that logger is imported and initialized (e.g., via import logging and logger = logging.getLogger(__name__)) before calling logger.info, otherwise this will raise a NameError.
        logger.info("Runner started successfully and is waiting for work from the API...")

Comment thread clarifai/runners/utils/code_script.py
@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
clarifai 43%
clarifai.cli 42%
clarifai.cli.templates 28%
clarifai.client 69%
clarifai.client.auth 66%
clarifai.constants 100%
clarifai.datasets 100%
clarifai.datasets.export 80%
clarifai.datasets.upload 75%
clarifai.datasets.upload.loaders 37%
clarifai.models 100%
clarifai.modules 0%
clarifai.rag 72%
clarifai.runners 11%
clarifai.runners.models 58%
clarifai.runners.pipeline_steps 45%
clarifai.runners.pipelines 85%
clarifai.runners.utils 62%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 58%
clarifai.utils 56%
clarifai.utils.evaluation 67%
clarifai.workflows 95%
Summary 62% (7329 / 11816)

Minimum allowed line rate is 50%

Copy link
Copy Markdown
Contributor

@mogith-pn mogith-pn left a comment

Choose a reason for hiding this comment

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

Looks good. Nothing from my side.

@luv-bansal luv-bansal merged commit 2e1cec2 into master Jul 17, 2025
10 checks passed
@luv-bansal luv-bansal deleted the back-linter-code-snippet branch July 17, 2025 12:30
srikanthbachala20 pushed a commit that referenced this pull request Jul 23, 2025
…logger once runner start (#705)

* VERSION-11.5.5

* Black linter to fix stylistic issues and ensure it follows to common Python standards

* better representation

* fix formatting

* fix formatting

* fix formatting
srikanthbachala20 added a commit that referenced this pull request Jul 23, 2025
* Initial plan

* Implement CLI config context fallback in BaseClient

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>

* Remove tests/test_base_client_cli_config.py file as requested

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>

* Remove tests/test_misc_cli_config.py as requested

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>

* [PR-725]: Using Config Context in Baseclient class

* Improve error message formatting and clarity in authentication

Co-authored-by: luv-bansal <70321430+luv-bansal@users.noreply.github.com>

* Add github folder download support and toolkit option in model init (#699)

* added github folder download support

* modified folder structure validation

* supported toolkit options for ollama

* fixed param name and toolkit bugs

* removed print in misc.py

* updated with log and raise

* Update clarifai/utils/misc.py

Co-authored-by: Srikanth Bachala <srikanth.bachala@clarifai.com>

---------

Co-authored-by: Srikanth Bachala <srikanth.bachala@clarifai.com>

* Improve client script formatting (black linter formatting) and added logger once runner start (#705)

* VERSION-11.5.5

* Black linter to fix stylistic issues and ensure it follows to common Python standards

* better representation

* fix formatting

* fix formatting

* fix formatting

* [PR-727]: Improve Local-Runner CLI Logging (#706)

* [PR-727]: Improve Local-Runner CLI Logging

* [PR-727]: Improve Local-Runner CLI Logging

* [PR-727]: Improve Local-Runner CLI Logging

* [PR-727]: Improve Local-Runner CLI Logging

* PR-323 Unit tests for toolkits. (#639)

* added initial vllm unit tests

* modified permissions for maintainer_tests.yml

* modified yaml file

* removed codecoverage for maintainer tests

* modified env vars for tests

* added labels to tests

* removed inputs in workflow disptach

* added pytest.ini

* removed unused functions

* added --enforce-eager option

* removed redundant URL logging

* Added Playground URL to Local-Runner Logs (#708)

* [PR-733] Improve URL Download error handling (#710)

* Improve error handling

* Improve error handling

* Improve error handling

* Added local-runner requirements validation step (#712)

* added local-runner requirements validation step

* added post check for ollama toolkit

* fixed tests

* [EAGLE-6460]:  Add func to return both stub and channel. (#713)

* Add func to return both stub and channel.

* tidy

* [PR-739] [PR-740] Unify Context Management Under a Single config Command (#709)

* Unify Context Management Under a Single context Command

* login func

* improvemensts and fix tests

* better alias

* active to current

* Unify config

* Update readme

* fix test

* update readme

* update readme

* update readme

* add set-context alias

* Initial plan

* [PR-725]: Using Config Context in Baseclient class

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>
Co-authored-by: Srikanth Bachala <srikanth.bachala@clarifai.com>
Co-authored-by: luv-bansal <70321430+luv-bansal@users.noreply.github.com>
Co-authored-by: mogith-pn <143642606+mogith-pn@users.noreply.github.com>
Co-authored-by: Patrick Lundquist <1460278+patricklundquist@users.noreply.github.com>
@luv-bansal luv-bansal mentioned this pull request Jul 23, 2025
srikanthbachala20 pushed a commit that referenced this pull request Jul 29, 2025
…logger once runner start (#705)

* VERSION-11.5.5

* Black linter to fix stylistic issues and ensure it follows to common Python standards

* better representation

* fix formatting

* fix formatting

* fix formatting
srikanthbachala20 added a commit that referenced this pull request Jul 29, 2025
* Initial plan

* Implement CLI config context fallback in BaseClient

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>

* Remove tests/test_base_client_cli_config.py file as requested

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>

* Remove tests/test_misc_cli_config.py as requested

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>

* [PR-725]: Using Config Context in Baseclient class

* Improve error message formatting and clarity in authentication

Co-authored-by: luv-bansal <70321430+luv-bansal@users.noreply.github.com>

* Add github folder download support and toolkit option in model init (#699)

* added github folder download support

* modified folder structure validation

* supported toolkit options for ollama

* fixed param name and toolkit bugs

* removed print in misc.py

* updated with log and raise

* Update clarifai/utils/misc.py

Co-authored-by: Srikanth Bachala <srikanth.bachala@clarifai.com>

---------

Co-authored-by: Srikanth Bachala <srikanth.bachala@clarifai.com>

* Improve client script formatting (black linter formatting) and added logger once runner start (#705)

* VERSION-11.5.5

* Black linter to fix stylistic issues and ensure it follows to common Python standards

* better representation

* fix formatting

* fix formatting

* fix formatting

* [PR-727]: Improve Local-Runner CLI Logging (#706)

* [PR-727]: Improve Local-Runner CLI Logging

* [PR-727]: Improve Local-Runner CLI Logging

* [PR-727]: Improve Local-Runner CLI Logging

* [PR-727]: Improve Local-Runner CLI Logging

* PR-323 Unit tests for toolkits. (#639)

* added initial vllm unit tests

* modified permissions for maintainer_tests.yml

* modified yaml file

* removed codecoverage for maintainer tests

* modified env vars for tests

* added labels to tests

* removed inputs in workflow disptach

* added pytest.ini

* removed unused functions

* added --enforce-eager option

* removed redundant URL logging

* Added Playground URL to Local-Runner Logs (#708)

* [PR-733] Improve URL Download error handling (#710)

* Improve error handling

* Improve error handling

* Improve error handling

* Added local-runner requirements validation step (#712)

* added local-runner requirements validation step

* added post check for ollama toolkit

* fixed tests

* [EAGLE-6460]:  Add func to return both stub and channel. (#713)

* Add func to return both stub and channel.

* tidy

* [PR-739] [PR-740] Unify Context Management Under a Single config Command (#709)

* Unify Context Management Under a Single context Command

* login func

* improvemensts and fix tests

* better alias

* active to current

* Unify config

* Update readme

* fix test

* update readme

* update readme

* update readme

* add set-context alias

* Initial plan

* [PR-725]: Using Config Context in Baseclient class

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>
Co-authored-by: Srikanth Bachala <srikanth.bachala@clarifai.com>
Co-authored-by: luv-bansal <70321430+luv-bansal@users.noreply.github.com>
Co-authored-by: mogith-pn <143642606+mogith-pn@users.noreply.github.com>
Co-authored-by: Patrick Lundquist <1460278+patricklundquist@users.noreply.github.com>
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.

3 participants