Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find out the state number for "Out of Service" in lab.py #192

Open
tianyizheng02 opened this issue Aug 11, 2024 · 1 comment · May be fixed by #205
Open

Find out the state number for "Out of Service" in lab.py #192

tianyizheng02 opened this issue Aug 11, 2024 · 1 comment · May be fixed by #205

Comments

@tianyizheng02
Copy link
Contributor

In lab.py, the comments state that there are 4 possible states for lab computers: "off", "available", "in use", and "out of service". We know that the first three states correspond to 0, 1, and 2 in the JSON API data, but we don't know the number corresponding to "out of service", at least not for certain. Currently, the code looks like

PittAPI/pittapi/lab.py

Lines 105 to 113 in 684d056

for computer_info in lab_data["state"].values():
if computer_info["up"] == 0:
off_computers += 1
elif computer_info["up"] == 1:
available_computers += 1
elif computer_info["up"] == 2:
in_use_computers += 1
else:
out_of_service_computers += 1

and ideally we should have

for computer_info in lab_data["state"].values():
    if computer_info["up"] == 0:
        off_computers += 1
    elif computer_info["up"] == 1:
        available_computers += 1
    elif computer_info["up"] == 2:
        in_use_computers += 1
    elif computer_info["up"] == UNKNOWN:
        out_of_service_computers += 1
    else:
        # Raise some kind of error

We should figure out this number somehow. By documenting it, we can handle the "out of service" case correctly and also test the case.

@winterqt
Copy link

winterqt commented Sep 2, 2024

It's 3. From the keyserve client JS:

O = [
  {
    off: 'free used gone',
    on: 'down',
    order: '1'
  },
  {
    off: 'down used gone',
    on: 'free',
    order: '0'
  },
  {
    off: 'down free gone',
    on: 'used',
    order: '2'
  },
  {
    off: 'down free used',
    on: 'gone',
    order: '3'
  }
]

var C = O[P.up] || O[3]

up in the status dict is the index into O, so 3 is "gone", aka out of service.

winterqt added a commit to winterqt/PittAPI that referenced this issue Sep 2, 2024
@winterqt winterqt linked a pull request Sep 2, 2024 that will close this issue
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 a pull request may close this issue.

2 participants