Skip to content

Conversation

@inimaz
Copy link
Collaborator

@inimaz inimaz commented Jun 16, 2025

Addresses #855 .

The cli will not show the traceback so the errors are not verbose. It will only show the error message.
This is because it does sys.exit() instead of Typer.Exit(). Typer shows the traceback by default.

@inimaz inimaz requested a review from benoit-cty June 16, 2025 18:52
@benoit-cty
Copy link
Contributor

benoit-cty commented Jun 16, 2025

Thanks !

Unfortunately, even with this branch I have the same behavior:

codecarbon-api on  fix/remove-traceback-cli [$?] via 🐍 v3.12.3 took 18s 
❯ hatch run codecarbon config
Welcome to CodeCarbon configuration wizard
Existing global config file found :
│ /media/data-nvme/dev/src/CODE_CARBON/codecarbon-api/codecarbon/cli/main.py:130 in _get_access_token                       │
│                                                                                                                           │
│   127 │   │   access_token = access_token_info["access_token"]                                                            │
│   128 │   │   return access_token                                                                                         │
│   129 │   except Exception as e:                                                                                          │
│ ❱ 130 │   │   raise ValueError(                                                                                           │
│   131 │   │   │   f"Not able to retrieve the access token, please run `codecarbon login` first                            │
│   132 │   │   ) 

@inimaz
Copy link
Collaborator Author

inimaz commented Jun 16, 2025

Weird... it works for me! Did you uninstall it first? I had to do hatch env prune so it works with my local version of hatch.

Hatch

~/:$ hatch run codecarbon config
Welcome to CodeCarbon configuration wizard
Existing global config file found :
Error: Not able to retrieve the access token, please run `codecarbon login` first! (error: )

With venv + pip install

python -m venv venv
source venv/bin/activate
pip install -e .
 ~/:$ codecarbon config
Welcome to CodeCarbon configuration wizard
Existing global config file found :
Error: Not able to retrieve the access token, please run `codecarbon login` first! (error: )

or if I do it via running it directly

:~/$ python -m codecarbon.cli.main config
Welcome to CodeCarbon configuration wizard
Existing global config file found :
Error: Not able to retrieve the access token, please run `codecarbon login` first! (error: )

Copy link
Contributor

@benoit-cty benoit-cty left a comment

Choose a reason for hiding this comment

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

Sorry, it works after a hatch prune 👍

@benoit-cty benoit-cty force-pushed the fix/remove-traceback-cli branch from 6adcf56 to 5239045 Compare June 22, 2025 07:57
@benoit-cty benoit-cty merged commit e5489e2 into master Jun 22, 2025
11 checks passed
@benoit-cty benoit-cty deleted the fix/remove-traceback-cli branch June 22, 2025 08:25
@benoit-cty benoit-cty mentioned this pull request Jul 11, 2025
6 tasks
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