pcdshub / pcdshub/engineering_tools

Error handling and output in some scripts could use tweaking: get_lastRun, get_curr_exp, ...

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5
Forks
36
Avg merge
2d 17h
Merged PRs (30d)
3

Description

Expected Behavior

  • If a hutch can't be determined or an experiment can't be found (for example), return a fixed value without error messages to the user
  • Wrapping these scripts with Python code is common and really should never fail, and should be usable on machines more typically used for testing

Current Behavior

As we were trying to make filenames for gige cameras to save to by way of hutch + experiment name + run number, we ran into the following:

[klauer@lfe-console  ~]$ /reg/g/pcds/engineering_tools/lfe/scripts/get_lastRun
ERROR:__main__:No runs?
Traceback (most recent call last):
  File "/reg/g/pcds/engineering_tools/R2.0.1/scripts/get_info", line 164, in <module>
    exp = resp.json().get("value", {}).get("name")
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
No runs taken yet
[klauer@lfe-console  ~]$ /reg/g/pcds/engineering_tools/lfe/scripts/get_hutch_name
lfe
[klauer@lfe-console  ~]$ /reg/g/pcds/engineering_tools/lfe/scripts/get_curr_exp
Traceback (most recent call last):
  File "/reg/g/pcds/engineering_tools/R2.0.1/scripts/get_info", line 158, in <module>
    exp = resp.json().get("value", {}).get("name")
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
/reg/g/pcds/engineering_tools/lfe/scripts/get_curr_exp: line 43: [: ==: unary operator expected

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the error paths around lines 158 and 164 of scripts/get_info, then inspect the get_curr_exp and get_lastRun wrappers. Reproduce the shown commands in a test environment and trace responses that are not valid JSON or contain no runs. Done means these cases return the intended fixed values without tracebacks or user-facing error messages.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.