-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Bug
When running clarifai model local-runner (or any command that calls _ensure_hf_token) from a directory without a config.yaml, the CLI produces a confusing sequence of outputs:
- A correct
[ERROR]log:config.yaml not found in model path. - A misleading
[WARNING]:Unexpected error ensuring HF_TOKEN:(with an empty message) - A full
AssertionErrortraceback fromModelBuilder._validate_folder
The expected behavior is that the CLI should abort cleanly at step 1 and never reach steps 2 or 3.
Root Cause
In clarifai/cli/model.py, the _ensure_hf_token function raises click.Abort() when config.yaml is missing (line 865), but the outer except Exception as e block (line 887) catches it:
try:
...
if not os.path.isfile(config_path):
logger.error("`config.yaml` not found in model path.")
raise click.Abort() # intended to stop execution
...
except Exception as e:
# catches click.Abort too — swallows the abort and downgrades it to a warning
logger.warning(f"Unexpected error ensuring HF_TOKEN: {e}")Since click.Abort() has no message string, {e} renders as empty, producing the cryptic Unexpected error ensuring HF_TOKEN: warning. Execution then continues past _ensure_hf_token, and the next thing that fails is the ModelBuilder assertion — producing a noisy traceback.
Fix
Add a specific except click.Abort: raise before the general except Exception handler so the abort propagates as intended:
except click.Abort:
raise
except Exception as e:
logger.warning(f"Unexpected error ensuring HF_TOKEN: {e}")Affected Commands
_ensure_hf_token is called by multiple CLI commands:
clarifai model uploadclarifai model download-checkpointsclarifai model local-runnerclarifai model local-grpcclarifai model signatures