Skip to content

Improve handling of unset username #375

@samsrabin

Description

@samsrabin

New feature type

Other (please explain below)

What is this new feature?

Currently, the user must set user in their config file in order to make plots. If they don't, they'll run into an unhelpful error (see below). It would be better for the ADF code to fall back to os.environ.get("USER"). If that's not possible for some reason, the code should throw a simple error telling the user to set the value in the config file.

Assistance required?

No, I will make a PR if/when the feature is ready

Extra info

Error when not setting user in the config file:

	Diagnostic Plot Location: /glade/derecho/scratch/USER-NAME-NOT-SET/ADF_unstruct/plots/b.e30_alpha06b.B1850C_LTso.ne30_t232_wgx3.143_30_40_vs_b.e30_alpha06b.B1850C_LTso.ne30_t232_wgx3.139_30_40
	INFO: Directory not found, making new diagnostic plot location
Traceback (most recent call last):
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/glade/derecho/scratch/USER-NAME-NOT-SET/ADF_unstruct/plots/b.e30_alpha06b.B1850C_LTso.ne30_t232_wgx3.143_30_40_vs_b.e30_alpha06b.B1850C_LTso.ne30_t232_wgx3.139_30_40'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/glade/derecho/scratch/USER-NAME-NOT-SET/ADF_unstruct/plots'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/glade/derecho/scratch/USER-NAME-NOT-SET/ADF_unstruct'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/glade/work/samrabin/ADF/./run_adf_diag", line 146, in <module>
    diag = AdfDiag(config_yaml, debug=config_debug)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/glade/work/samrabin/ADF/lib/adf_diag.py", line 191, in __init__
    super().__init__(config_file, debug=debug)
  File "/glade/work/samrabin/ADF/lib/adf_web.py", line 101, in __init__
    super().__init__(config_file, debug=debug)
  File "/glade/work/samrabin/ADF/lib/adf_obs.py", line 64, in __init__
    super().__init__(config_file, debug=debug)
  File "/glade/work/samrabin/ADF/lib/adf_info.py", line 649, in __init__
    diag_location.mkdir(parents=True)
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1120, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1120, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1120, in mkdir
    self.parent.mkdir(parents=True, exist_ok=True)
  File "/glade/work/samrabin/conda-envs/ldf_v0.0/lib/python3.11/pathlib.py", line 1116, in mkdir
    os.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/glade/derecho/scratch/USER-NAME-NOT-SET'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions