[change] Adjust settings to use new bw2data.projects method#8
[change] Adjust settings to use new bw2data.projects method#8dgdekoning wants to merge 2 commits intocauldron:bw25from
Conversation
|
Included in this MR are:
|
Haven't worked on this in quite a while
| self.data_dir = directory | ||
| self.filename = filename or "default_settings.json" | ||
| self.settings_file = os.path.join(self.data_dir, self.filename) | ||
| self.data_dir: str = directory |
There was a problem hiding this comment.
Should this also be an instance of pathlib.Path? We found it really convenient to have everything in bw2data be a Path, but maybe that is more trouble than it is worth here.
| """Update old settings, backwards compatibility method. | ||
|
|
||
| This function is only required for compatibility with the old settings file | ||
| and can be removed in a future release. |
There was a problem hiding this comment.
Any idea how old the old settings file is? Maybe we can remove this method now?
There was a problem hiding this comment.
It looks like the change it at least 4 years ago, so it should be fine to remove yes.
| """Returns the custom brightway directory, or the default""" | ||
| return self.settings.get("custom_bw_dirs", self.get_default_directory()) | ||
| """Returns the custom brightway directory, or the default.""" | ||
| return self.settings.get("custom_bw_dirs") or str(bw2data.projects._base_data_dir) |
There was a problem hiding this comment.
This is an important point, and I think we should document it more clearly. AFAICT there is a "default" directory set at startup, and this is what we can revert to at anytime. We can also change the data directory, but the only history of these changes that is made is that we remember the "default" directory.
| NOTE: discards the biosphere3 database based on name. | ||
| """ | ||
| iterator = self.settings.get("read-only-databases", {}).items() | ||
| return (name for name, ro in iterator if not ro and name != "biosphere3") |
There was a problem hiding this comment.
We need to make biosphere3 configurable, this will change in the future (there won't be just one string). We can either add it to the custom AB settings, or refer to bw2data.config.biosphere.
There was a problem hiding this comment.
Will have a look at the code for the bw2data implementation. Would prefer using the brightway standards.
|
|
||
| def bw_projects(self, path: str): | ||
| """Finds the bw_projects from the brightway2 environment provided by path""" | ||
| def bw_projects(self, path: str) -> List[str]: |
There was a problem hiding this comment.
Can you help me understand this? The RE does... not much, and why wouldn't we just read the projects from the projects.db database. There isn't any guarantee that each directory is a project.
There was a problem hiding this comment.
So it looks like this bw_projects call was added after I stopped working on the AB and I can't explain why it was added here...
Will set up a separate 'unchanged' environment to see how it is being used.
This MR is related to #3.
The
wasmbranch in bw2data contains the new method that handles changing the brightway data directory.Checklist
bug,feature,ui,change,documentation,breaking,cias they show up in the changelog