Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Startup Project does not list same projects as the Projects tab #1074

Closed
1 task done
bsteubing opened this issue Oct 14, 2023 · 5 comments · Fixed by #1194
Closed
1 task done

Startup Project does not list same projects as the Projects tab #1074

bsteubing opened this issue Oct 14, 2023 · 5 comments · Fixed by #1194
Labels
bug Issues/PRs related to bugs good first issue Issues to get started with AB development with
Milestone

Comments

@bsteubing
Copy link
Member

bsteubing commented Oct 14, 2023

Updating AB

  • Yes, I have updated AB and still experience this issue

What happened?

When trying to set a recent project as the "startup project" in settings, I notice that the list of projects there is different and does not include the projects I recently created.

List in Projects
image

List in Settings > Startup Project:
image

Relevant errors

No response

Operating system

Windows 10

Conda environment

No response

@bsteubing bsteubing added the bug Issues/PRs related to bugs label Oct 14, 2023
@Zoophobus
Copy link
Contributor

I'll check this in the coming week/s, just a quick question, as I have a suspicion that this is due to the reading of the settings file, was this all in one session with the AB? If you close and reload the AB do the listed projects match?

@bsteubing
Copy link
Member Author

It does not change if the AB is closed and reopened... there is simply a mismatch between the two and what the AB settings reads is not up to date, so there the call is probably wrong...

@marc-vdm
Copy link
Member

I think this is caused by the following function:

def update_project_combo(self, initialization: bool = True, path: str = None):

This function actually reads the Brightway dir (in your case C:\Users\steub\OneDrive - Universiteit Leiden\Brightway3) with our own function (self.bw_projects(path)) while the dropdown in the projects tab reads the projects from Brightway:

self.project_names = sorted([project.name for project in projects])

What I propose is that we move self.bw_projects(path) (perhaps under a different name) to the ProjectController and then have the projects tab and the settings wizard read from there.

@marc-vdm marc-vdm added this to the 2.9.3 milestone Nov 7, 2023
@marc-vdm marc-vdm added the good first issue Issues to get started with AB development with label Nov 7, 2023
mrvisscher added a commit to mrvisscher/activity-browser that referenced this issue Nov 20, 2023
@mrvisscher
Copy link
Collaborator

mrvisscher commented Nov 20, 2023

If I understand your sollution correctly @marc-vdm your sollution would lead to the startup project list not updating when a new brightway dir is selected as the ProjectController is only updated after hitting save in the settings wizard. I'd suggest updating self.bw_projects(path) to read the projects from the db file in said path directly. Like so:

def bw_projects(self, path: str):
        """ Read the bw_projects from the brightway2 environment provided by path"""
        db = SqliteDatabase(os.path.join(path, "projects.db"))
        cursor = db.execute_sql('SELECT "name" FROM "projectdataset"')
        return [ i[0] for i in cursor.fetchall()]

Also see the commit above

@marc-vdm marc-vdm modified the milestones: 2.9.3, 2.9.4 Dec 4, 2023
@mrvisscher mrvisscher removed this from the 2.9.4 milestone Jan 9, 2024
@marc-vdm marc-vdm added this to the 2.9.4 milestone Jan 9, 2024
marc-vdm pushed a commit that referenced this issue Jan 9, 2024
* Settings Wizard read Projects from Database #1074

* Fixed unsafe path

* Added comments
Copy link

github-actions bot commented Jan 9, 2024

Note

This issue has been implemented in the new release of Activity Browser 🚀 (version 2.9.4), you can get the new version by updating Activity Browser.

Do you want to be notified of new releases of Activity Browser? Subscribe to our updates mailing list ✉.

🤖_beep boop! I'm a bot and this message was an automated action._
If updating does not make sense for this issue, just ignore this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues/PRs related to bugs good first issue Issues to get started with AB development with
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants