Skip to content

Enhancement request for script dir and error logging #872

@aweaver1fandm

Description

@aweaver1fandm

Use case:
We have created a conda environment for birdnet which sits in our /opt directory. We have permissions set
for conda environments so that regular users can't write to that directory because we've had issues in the past with folks destroying the environments (many of which are shared among multiple users).

In this setup we are not able to run birdnet because utils.py and config.py(and possibly other things) hard code error and script directories to be where the script is installed resulting in the following set of errors:

Missing BirdNET_GLOBAL_6K_V2.4_Model/variables/variables.data-00000-of-00001
Traceback (most recent call last):
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/utils.py", line 27, in wrapper
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/analyze/cli.py", line 29, in main
    analyze(**vars(args))
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/analyze/core.py", line 78, in analyze
    flist = _set_params(
            ^^^^^^^^^^^^
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/analyze/core.py", line 165, in _set_params
    ensure_model_exists(check_perch=use_perch)
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/utils.py", line 444, in ensure_model_exists
    os.makedirs(checkpoint_dir, exist_ok=True)
  File "<frozen os>", line 225, in makedirs
PermissionError: [Errno 13] Permission denied: '/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/checkpoints'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/analyze/__main__.py", line 3, in <module>
    main()
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/utils.py", line 29, in wrapper
    write_error_log(ex)
  File "/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/utils.py", line 294, in write_error_log
    with open(cfg.ERROR_LOG_FILE, "a") as elog:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

PermissionError: [Errno 13] Permission denied: '/opt/miniconda3/envs/birdnet/lib/python3.11/site-packages/birdnet_analyzer/error_log.txt'

We would like these to either be set via a command line option or if they have to hard coded, perhaps hard coded to somewhere like /tmp

Metadata

Metadata

Assignees

No one assigned

    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