diff --git a/clarifai/cli/model.py b/clarifai/cli/model.py index 4337ab62..6a37d1bc 100644 --- a/clarifai/cli/model.py +++ b/clarifai/cli/model.py @@ -2022,10 +2022,17 @@ def _get_saved(key): public_visibility = resources_pb2.Visibility( gettable=resources_pb2.Visibility.Gettable.PUBLIC ) + app_exists = True try: app = user.app(app_id) - out.status("App ready") except Exception: + app_exists = False + + if app_exists: + # Ensure the app has PUBLIC visibility (required for public models) + user.patch_app(app_id, visibility=resources_pb2.Visibility.Gettable.PUBLIC) + out.status("App ready") + else: out.status("Creating app... ", nl=False) app = user.create_app(app_id, visibility=public_visibility) click.echo("done") diff --git a/tests/cli/test_local_runner_cli.py b/tests/cli/test_local_runner_cli.py index c92d4a8d..acbdd546 100644 --- a/tests/cli/test_local_runner_cli.py +++ b/tests/cli/test_local_runner_cli.py @@ -299,6 +299,11 @@ def validate_ctx_mock(ctx): # Existing resources not re-created mock_user.create_compute_cluster.assert_not_called() mock_user.create_app.assert_not_called() + # Existing app patched to PUBLIC visibility + mock_user.patch_app.assert_called_once() + patch_kwargs = mock_user.patch_app.call_args + assert patch_kwargs[0][0] == "local-runner-app" # app_id positional arg + assert patch_kwargs[1]["visibility"] == 50 # PUBLIC gettable enum value # But version IS always created fresh mock_user.app().model().create_version.assert_called_once()