Closed claell closed 7 months ago
The configuration is not portable, no. But that's why by default it's not part of the project you're running pybliometrics in. Yet you can set it up that way, see https://pybliometrics.readthedocs.io/en/stable/configuration.html#custom-location.
My intention was to let each user of say a shared repo where pybliometrics is part of set its own location. Meaning, users configure pybliometrics once, and that's it.
Yes, I saw that. Problem is that paths are kind of "hard coded" in the config file, so if I add it to the project folder, every user will have my cache directory (C:/Users/Username
) and it will break for them. I changed the paths there to relative paths, but it's not really straight-forward.
I thought about this a bit and I want to change this. I want to introduce a mandatory
pybliometrics.init()
statement, which loads the configuration. Instead of loading it during import. Users can optionally provide the link to the configuration file in this statement.
Sounds good to me, as that will also fix problems where auto formatting messes up the order of
import os
os.environ['PYB_CONFIG_FILE'] = "C:/Custom/Location/pybliometrics.cfg"
import pybliometrics
For this particular issue, I was looking for some function like
pybliometrics.set_base_directory()
which sets the base directories for all directories in the config:
[Directories]
AbstractRetrieval = PPP/.pybliometrics/Scopus/abstract_retrieval
AffiliationSearch = PPP/.pybliometrics/Scopus/affiliation_search
AuthorRetrieval = PPP/.pybliometrics/Scopus/author_retrieval
AuthorSearch = PPP/.pybliometrics/Scopus/author_search
CitationOverview = PPP/.pybliometrics/Scopus/citation_overview
AffiliationRetrieval = PPP/.pybliometrics/Scopus/affiliation_retrieval
ScopusSearch = PPP/.pybliometrics/Scopus/scopus_search
SerialTitle = PPP/.pybliometrics/Scopus/serial_title
(Basically replacing the PPP
for all entries, I guess).
The init change will be handled in #311 soon. This will constitute pybliometrics 3.0. Maybe we can augment this with an option to pass on keys. Then the configuration is fixed per project but the keys are not. We will also make sure that the paths can be relative.
But there will not be a function to replace base directories in a configuration file. That is such an easy thing to do in an editor, it's really not worth the time to write code for it.
pybliometrics version: 3.5.2
Affected classes: -
Expected behavior: Currently, the configuration contains absolute paths to a user's directory. That way, a project is not really portable.
Either the config is stored on each machine individually (then the API key needs to be set on every machine, see #294), or the config location is changed to a synced folder (then the directories are not portable).
Workaround might be to set the directories at runtime.