neulab / explainaboard_client

1 stars 1 forks source link

Fix user-related args in CLI by reading from env vars #49

Closed OscarWang114 closed 1 year ago

OscarWang114 commented 1 year ago

Problem

The original command (as shown below) in README failed with 401 unauthorized (No authorization token provided), and the root cause is that explainaboard_client.username and explainaboard_client.api_key are both set to None (likely due to this change to remove env vars from the library as suggested in the discussion).

Original command

python -m explainaboard_client.cli.evaluate_system \
  --task text-classification \
  --system-name text-classification-test \
  --system-output-file example/data/sst2-lstm-output.txt \
  --system-output-file-type text \
  --dataset sst2 \
  --split test \
  --source-language 'en' 

Solution

I read the env vars in the CLI parser and pass it into the library. I believe this adheres to the practice that "CLI is allowed to use reserved env vars, but not the library?" Looping in @odashi to double check if I'm on the right track

parser.add_argument(
    "--username",
    type=str,
    default=os.environ.get("EB_USERNAME"),
    help="Username used to sign in to ExplainaBoard. Defaults to the EB_USERNAME "
    "environment variable.",
)