Skip to content

Allow user-configurable configuration and cache directory locations#337

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/change-configuration-location
Draft

Allow user-configurable configuration and cache directory locations#337
Copilot wants to merge 2 commits into
mainfrom
copilot/change-configuration-location

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

BioServicesConfig offered no way to override the config/cache paths — both were read-only properties delegating to appdirs.AppDirs.

Changes

src/bioservices/settings.py

  • New BioServicesAppDirs(appdirs.AppDirs) — subclass that promotes user_config_dir and user_cache_dir to read/write properties; a custom path is used when set, falling back to the appdirs platform default when reset to None. Exported via __all__.
  • ConfigReadOnly.__init__ now accepts user_config_dir and user_cache_dir kwargs; forwards them to BioServicesAppDirs before init() runs. Also fixes the pre-existing mutable default argument (default_params={}None).
  • BioServicesConfig.__init__ forwards the same kwargs up the chain.

test/test_units.py

  • Added TestBioServicesAppDirs and TestCustomConfigDir covering property overrides, constructor-time injection, and post-construction mutation.

Usage

# At construction time
from bioservices.settings import BioServicesConfig
cfg = BioServicesConfig(user_config_dir="/my/custom/config")

# Or post-construction (requires re-init to reload from new path)
cfg = BioServicesConfig()
cfg.appdirs.user_config_dir = "/my/custom/config"
cfg.init()

# Works through service instances too
from bioservices import UniProt
u = UniProt()
u.settings.appdirs.user_config_dir = "/my/custom/config"
u.settings.init()
Original prompt

This section details on the original issue you should resolve

<issue_title>Changing configuration location</issue_title>
<issue_description>Dear all,

I am willing to change the configuration location for bioservices but I do not see how to do it since the class BioServicesConfig allows to change the default but not the path.

¿Recommendations?

Thanks</issue_description>

Comments on the Issue (you are @copilot in this section)

@cokelaer Short answer: this is not possible unfortunately.

Long answer: The configuration framework used in bioservices, comes from easydev package where I used the appdirs package itself. This package takes care of dealing with config files directory on different OS platform. In the BioServicesConfig class, it uses easydev.appdirs and the configuration location is a read-only property stored in the attribute settings.appdirs.user_config_dir where settings is the attribute of all bioservices services classes. For instance:

from bioservices import UniProt
u = UniProt()
u.settings.appdirs.user_config_dir

Note that I am changing the API little by little and future version with have the following API:

from bioservices import UniProt
u = UniProt()
u.services.settings.appdirs.user_config_dir

Now, saying that this attribute (user_config_dir) is read-only so you cannot change it. That would required to change easydev package and the module appdirs. Another solution is to create a class that inherits from Appdirs and use it in bioservices.settings. The user_config_path could then be changed as write/read property</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: cokelaer <778821+cokelaer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix configuration location for bioservices Allow user-configurable configuration and cache directory locations Mar 17, 2026
Copilot AI requested a review from cokelaer March 17, 2026 22:46
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 this pull request may close these issues.

Changing configuration location

2 participants