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

Setup without test data #86

Open
ccgauvin94 opened this issue Oct 18, 2023 · 12 comments
Open

Setup without test data #86

ccgauvin94 opened this issue Oct 18, 2023 · 12 comments

Comments

@ccgauvin94
Copy link

I've gotten EMHub running with the test data. However, when I try to delete some of the test data instruments, I can an error on the dashboard page:

'NoneType' object has no attribute 'tags'

Traceback (most recent call last):
  File "/opt/scipion/source/core/emhub/emhub/__init__.py", line 387, in get_content
    kwargs = app.dc.get(**content_kwargs)
  File "/opt/scipion/source/core/emhub/emhub/data/content/dc_base.py", line 73, in get
    dataDict.update(get_func(**kwargs))
  File "/opt/scipion/source/core/emhub/emhub/data/content/dc_base.py", line 80, in wrapper
    return func(**kwargs)
  File "/opt/scipion/source/core/emhub/emhub/data/content/dc_base.py", line 880, in dashboard
    if local_tag in r.tags:
AttributeError: 'NoneType' object has no attribute 'tags'

If I try setting the data folder to an empty folder, I can't log into EMHub with the admin/admin login. Is there a way to set up EMHub without using the test data?

@delarosatrevin
Copy link
Member

Could you try in the 'devel' branch?

I'm about to release the newest changes to the main branch, but not done yet.

After changing to devel remember to do: pip install - e .
Then:
emh-data --create_instance
This will create the instance folder by default here: ~/.emhub/instances/test
and read the config from the json file: https://github.com/3dem/emhub/blob/devel/emhub/data/imports/test_instance_data.json

I tested and I could login as admin/admin and also delete resources. You need to setup somehow an initial instance before starting EMhub.

You can pass arguments to emt-data --create_instance and pass a different location and also a different json file. So you can try to copy the default one and modify 'resources', 'users' and other settings there.

@ccgauvin94
Copy link
Author

Thanks for the quick reply! The same problem occurred on the dev branch, but I edited the .json file to wipe out all the existing users, bookings, and instruments.

That mostly worked - projects, invoices, and reports are broken, but perhaps because there's no data.

@delarosatrevin
Copy link
Member

You couldn't remove resources as admin? That's weird, I was able to delete it from the interface after login.

Projects page is broken because it is missing some new values in the config file, I will fix that.
Invoices page is broken because I moved it to the "Stockholm" variant, but might bring it back to the main track.

But you should be able to see Sessions and Reports.

@ccgauvin94
Copy link
Author

ccgauvin94 commented Oct 18, 2023

I could remove it, but then when I try to load the dashboard afterwards, is when I'd get the above error.

I'm now running to an issue where I can't add users, perhaps this has to do with my custom .json?

sqlalchemy.exc.InterfaceError: (sqlite3.InterfaceError) Error binding parameter 8 - probably unsupported type.
[SQL: INSERT INTO users (username, email, phone, name, created, status, roles, password_hash, profile_image, pi_id, extra) VALUES (?, ?, ?, ?, (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), ?, ?, ?, ?, ?, ?) RETURNING id, created]
[parameters: ('colingauvin@montana.edu', 'colingauvin@montana.edu', '', 'colin', 'active', '["user", "admin", "manager", "independent", "staff-cryoem"]', 'sha256$EJjVEjrbzJGsXAKm$8411fc7011854c69be22bd2165ca771056e581f10c2a90ef05cb345e625f1887', None, {}, '{}')]

It looks like field 8 is None. Perhaps that's supposed to be PI?

@delarosatrevin
Copy link
Member

Ok, I think I now know about what's happening. You have removed a Resource that is tried later to be displayed in the Dashboard. I will add a nicer message for that or just ignore that resource.

I think the error is that you are trying to add an existing email, that field needs to be unique for each user. Here a better message is needed. Thanks for the feedback.

@ccgauvin94
Copy link
Author

ccgauvin94 commented Oct 18, 2023

OK, as it is, it blocks any of the dashboard page from actually being displayed.

I think the error is that you are trying to add an existing email, that field needs to be unique for each user. Here a better message is needed. Thanks for the feedback.

All I have is the admin user:
image
So I don't think it's that the email is in use.

Btw, EMHub looks absolutely fantastic and seems to check all the major boxes. Very impressive work.

EDIT: It must be my custom .json file, because I can add users just fine in the default test data one.

@delarosatrevin
Copy link
Member

I found the issue with the Dashboard, it is that you might have removed Resources that are used in the bookings. I need to add validation for that since every existing booking should be associated with a Resource.

Are you missing any fields for users from your custom JSON?

Thanks for your positive words!

@ccgauvin94
Copy link
Author

OK, I made a new .json file. I removed all projects, bookings, and sessions, and left the instruments and users alone. Then, after starting the server, I deleted the instruments and users in the GUI without any obvious issue. I was also able to add new users.

I think that's as far as I can test, because I need the Projects working to make a booking, it seems. But I'll wait for the Projects to start working and test again at that point.

Thanks so much for you help.

@delarosatrevin
Copy link
Member

You can fix the project config easily, I will correct that for the default instance creation.

Just add the following before the last brace in the JSON definition of Form -> config:permission:

,
    "projects": {
        "can_create": "all",
        "view_options": [
            {
                "key": "mine",
                "label": "My Projects"
            },
            {
                "key": "lab",
                "label": "Lab's Projects"
            },
            {
                "key": "all",
                "label": "All Projects"
            }
        ]
        
    }

After that you should get back the Projects page.

@ccgauvin94
Copy link
Author

Great, thanks! Projects page is working.

@ccgauvin94
Copy link
Author

New issue: I tried to reset the password of the newly created account (not sure how else to get the password?) and I get this error:

Traceback (most recent call last):
  File "/home/cryoem/emhub/emhub/__init__.py", line 387, in get_content
    kwargs = app.dc.get(**content_kwargs)
  File "/home/cryoem/emhub/emhub/data/content/dc_base.py", line 71, in get
    raise Exception(f"Missing content function for '{content_id}'")
Exception: Missing content function for 'user_reset_password'

I do have SMTP setup (I think, but no way to verify).

@delarosatrevin
Copy link
Member

As admin you can set the password from any user, editing the user from the list. That user_reset_password page will require a SMTP setup for sending an email with the reset password token. I need to further test that part because we are not using it now.

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

No branches or pull requests

2 participants