Skip to content

Local Runner Public by default#981

Merged
luv-bansal merged 1 commit intomasterfrom
local-runner-public
Mar 17, 2026
Merged

Local Runner Public by default#981
luv-bansal merged 1 commit intomasterfrom
local-runner-public

Conversation

@luv-bansal
Copy link
Copy Markdown
Contributor

@luv-bansal luv-bansal commented Mar 11, 2026

Pull request overview

This PR changes the default visibility of resources created/used by the “local runner” flow so they are PUBLIC by default (intended to make locally served models more easily shareable/accessible through Clarifai).

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 changes the default visibility of resources created/used by the “local runner” flow so they are PUBLIC by default (intended to make locally served models more easily shareable/accessible through Clarifai).

Changes:

  • Set default local-runner compute cluster and nodepool configs to PUBLIC visibility.
  • Update clarifai model serve to create the app, model, model version, and deployment with PUBLIC visibility.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.

File Description
clarifai/utils/constants.py Adds PUBLIC visibility defaults to local runner compute cluster/nodepool config dicts.
clarifai/cli/model.py Applies PUBLIC visibility when creating local runner app/model/version and sets deployment visibility to PUBLIC.

Comment on lines +65 to +67
"visibility": {
"gettable": 50, # PUBLIC
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Avoid hard-coding the enum value 50 for PUBLIC visibility. Consider using resources_pb2.Visibility.Gettable.PUBLIC (or a named constant) here as well, for consistency and to reduce the risk of enum value drift.

Copilot uses AI. Check for mistakes.
Comment thread clarifai/cli/model.py
Comment on lines 2005 to 2009
version_model = model.create_version(
pretrained_model_config={"local_dev": True},
method_signatures=method_signatures,
visibility=public_visibility,
)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

There are existing tests for clarifai model serve (see tests/cli/test_local_runner_cli.py), but they don’t currently assert that resources are created with PUBLIC visibility. Please add assertions that create_app, create_model, create_version, and create_deployment are called with the expected visibility to prevent regressions.

Copilot uses AI. Check for mistakes.
Comment thread clarifai/cli/model.py
Comment on lines +2064 to +2066
"visibility": {
"gettable": resources_pb2.Visibility.Gettable.PUBLIC,
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Making the deployment PUBLIC by default is a high-impact security change. Consider making this configurable (flag/config), and/or printing the final shared URL with an explicit warning so users understand the exposure they’re enabling.

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +38
"visibility": {
"gettable": 50, # PUBLIC
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Setting the local runner compute cluster visibility to PUBLIC changes who can discover/read this resource. If the intent is only to make the served model shareable, consider keeping infra resources (compute cluster/nodepool) private by default, or making this configurable via a CLI flag / config option.

Copilot uses AI. Check for mistakes.
"min_instances": 1,
"max_instances": 1,
"visibility": {
"gettable": 50, # PUBLIC
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Making the default local runner nodepool PUBLIC can expose resource metadata to other users depending on platform ACL semantics. If public sharing is only needed for prediction, consider leaving the nodepool private by default and only making the app/model/version/deployment public (or make this behavior opt-in).

Suggested change
"gettable": 50, # PUBLIC
"gettable": 10, # PRIVATE

Copilot uses AI. Check for mistakes.
Comment thread clarifai/cli/model.py
Comment on lines +1968 to 1978
# Public visibility so anyone with the URL can send predictions
public_visibility = resources_pb2.Visibility(
gettable=resources_pb2.Visibility.Gettable.PUBLIC
)
try:
app = user.app(app_id)
out.status("App ready")
except Exception:
out.status("Creating app... ", nl=False)
app = user.create_app(app_id)
app = user.create_app(app_id, visibility=public_visibility)
click.echo("done")
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Defaulting the local runner’s app/model/version visibility to PUBLIC is a security-sensitive change (it can unintentionally expose models to broader audiences). Consider requiring an explicit opt-in flag (e.g., --public), or at least printing a prominent warning + providing a --private override to avoid accidental exposure.

Copilot uses AI. Check for mistakes.
Comment thread clarifai/cli/model.py
Comment on lines 1972 to 1978
try:
app = user.app(app_id)
out.status("App ready")
except Exception:
out.status("Creating app... ", nl=False)
app = user.create_app(app_id)
app = user.create_app(app_id, visibility=public_visibility)
click.echo("done")
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Visibility is only applied when creating the app. If the app already exists (possibly created by an older version of this command with private visibility), this path won’t update it to PUBLIC, so “public by default” may not take effect for existing users. Consider checking/patching existing app visibility (e.g., via User.patch_app) or warning when it’s not public.

Copilot uses AI. Check for mistakes.
Comment thread clarifai/cli/model.py
Comment on lines +1997 to +1999
model = app.create_model(
model_id, model_type_id=model_type_id, visibility=public_visibility
)
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Visibility is only applied when creating the model. If an existing model is found, its visibility is left unchanged, which can conflict with the new “public by default” behavior. Consider checking/patching existing model visibility (e.g., App.patch_model) or at least emitting a warning when it’s not public.

Copilot uses AI. Check for mistakes.
Comment thread clarifai/cli/model.py
],
"deploy_latest_version": True,
"visibility": {
"gettable": resources_pb2.Visibility.Gettable.PUBLIC,
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

public_visibility is created as a resources_pb2.Visibility proto, but deployment visibility is set via a separate inline dict and repeats the enum reference. Consider reusing the already-defined value (e.g., use public_visibility.gettable) to keep visibility handling consistent and reduce duplication.

Suggested change
"gettable": resources_pb2.Visibility.Gettable.PUBLIC,
"gettable": public_visibility.gettable,

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +38
"visibility": {
"gettable": 50, # PUBLIC
},
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

Avoid hard-coding the enum value 50 for PUBLIC visibility. Since this dict is later converted to resources_pb2.Visibility(**...), consider using resources_pb2.Visibility.Gettable.PUBLIC (or a named constant in this module) to prevent silent breakage if enum values ever change and to improve readability.

Copilot uses AI. Check for mistakes.
@ackizilkale
Copy link
Copy Markdown
Contributor

All good, but make sure to write content into PR description

@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
clarifai 45%
clarifai.cli 61%
clarifai.cli.templates 67%
clarifai.cli.templates.toolkits 100%
clarifai.client 65%
clarifai.client.auth 67%
clarifai.constants 100%
clarifai.datasets 100%
clarifai.datasets.export 69%
clarifai.datasets.upload 75%
clarifai.datasets.upload.loaders 37%
clarifai.models 100%
clarifai.rag 0%
clarifai.runners 52%
clarifai.runners.models 58%
clarifai.runners.pipeline_steps 39%
clarifai.runners.pipelines 72%
clarifai.runners.utils 62%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 58%
clarifai.utils 65%
clarifai.utils.evaluation 16%
clarifai.workflows 95%
Summary 60% (11348 / 18953)

Minimum allowed line rate is 50%

@luv-bansal luv-bansal merged commit 1ca9e13 into master Mar 17, 2026
18 of 21 checks passed
@luv-bansal luv-bansal deleted the local-runner-public branch March 17, 2026 07:30
@ackizilkale ackizilkale mentioned this pull request Mar 18, 2026
2 tasks
Copilot AI mentioned this pull request Mar 19, 2026
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