Skip to content

Issues with Client initialization from keyfile #103

Description

@frobnitzem

I created my keyfile as described in the docs.

$ ls -l ~/.superfacility/
total 4
-rw-------+ 1 username group 1693 Oct 24 08:48 key.pem

However, when I initialize a client, several things go wrong.

  1. If no key= argument is given, then client.token is not initialized. I assume the keyfile wasn't found.

  2. Using a key= argument, client.token and client._client_id are set, but client._access_token is missing, and there is no "Authorization" header set.

  3. Submitting a test job gives a hard-to-use error "sfapi_client.exceptions.SfApiError: sbatch: error: Job request does not match any supported policy." It could be right, but it doesn't give a good hint on how to fix my job script / what policy to check.

import os
from pathlib import Path

from sfapi_client import Client
from sfapi_client.compute import Machine

# with Client() as client: # (1.)
keypath = Path(os.environ["HOME"]) / ".superfacility" / "key.pem"
with Client(key=keypath) as client:
    assert client.token is not None # (1.)

    # (2.) The following vars are not setup on construction using key= initialization.
    client._access_token = client.token
    client._http_client().headers.update(
        {"Authorization": "Bearer " + str(client.token)}
    )
    print(client._client_id, client._access_token)
    assert "Authorization" in client._http_client().headers # (2.)
    machine = client.compute(Machine.perlmutter)
    job = machine.submit_job("""#!/bin/bash
#SBATCH -N 2
#SBATCH -t 2
#SBATCH -A m3792
pwd
""") # (3.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions