Skip to content

Conversation

@lmarini
Copy link
Member

@lmarini lmarini commented Apr 7, 2023

Example of how to use benie to list datasets (using mongo views). There is new objects for DatasetsDB and AuthorizationDB. Both have been replaced in most places (not all). I left the old code there for comparison but it should be removed before it is merged.

I couldn't figure out a way to return id from fastapi instead of _id so for now we replace _id with id in the javascript after the ajax call. If we decided to adopt benie we could change frontend to use _id.

To test migrations you have to provide database flag with -db. If you put it in the URI it will not work:

beanie migrate -uri "mongodb://localhost" -db clowder2 -p app/models/migrations

Migrations are explained here https://beanie-odm.dev/tutorial/migrations/.

lmarini added 10 commits March 30, 2023 14:57
FIXME endpoints return MongoDB `_id` but javascripts expects `id`.
error regarding no database name provided.
# Conflicts:
#	backend/Pipfile
#	backend/Pipfile.lock
#	backend/app/routers/authorization.py
#	frontend/package-lock.json
#	frontend/package.json
#	frontend/src/openapi/v2/services/AuthService.ts
#	frontend/src/types/data.ts
#	frontend/src/utils/common.js
@longshuicy longshuicy linked an issue Apr 25, 2023 that may be closed by this pull request
Copy link
Member

@longshuicy longshuicy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason I cannot see any datasets. Do i need to drop the database?
image

longshuicy and others added 16 commits May 8, 2023 14:26
* import container (#462)

* 446 gui to manage api keys (#465)

* add new routes placeholder

* add list and delete endpoint; inline docs

* codegen and pytest

* ugly ui?

* onstart clear user keys

* delete works but pytest doesn't work yet

* pytest all works

* codegen

* redux

* reducer and types

* write the table

* correctly wire in the apikey and error handling

* wire in the delete modal of apikeys

* wire in the creation api key

* everything working in the gui

* formatting

---------

Co-authored-by: toddn <[email protected]>

* Sharing tab cleanup (#430)

* fix bug where users not being fetched

* simplifying role query pt 1

* refactor tables and API calls

* cleanup

* start moving GroupAndRole to separate table

* add expanding sub table

* remove AddGroup buttons for now

* formatting

* codegen

* add response model

* codegen

* remove container

* fix bug with Roles return object and autocomplete on groups

* codegen

* Fix reload bug (#451)

* 461 fix library version in pipfile (#468)

* fix pipfile version

* regenerate the piplock file

* 443 frontend need to display more verbose backend error (#458)

* Updated frontend error message to be more verbose

* Backend returns verbose logs, frontend displays it as generic messages depending on the HTTP status code

* Updated the error message logic to include original backend logs wherever possible

* Fixed report button issue

* Rootcause: The onClick event for the report button has a semantic error, which is causing the issue reason string to be replaced with an object

* Also added encode for the reason

* Fixing issue with error message

* Revert "Updated frontend error message to be more verbose"

This reverts commit 7d230d3.

* Fixing issue with error message

* 469 create profile page (#471)

* profile page exists

* new route for user profile
profile page includes layout

* codegen new route for get current user profile

* we now get the profile, but nothing shows yet

* page has fake data

* we see the profile now

* formatting

* Implemented role delete in sharing tab (#472)

* Tested by deleting a user, group. Verified entry is removed upon refresh

* Show Creator on Group Page (#428)

* the owner is visible, and we cannot change the owner in the table

* showing group creator on top

* creator link is wrong, need to fix

* bold text for word 'creator'

* using more conditionals to reduce duplicate code

* missing modal added
creator name matches other names

---------

Co-authored-by: Chen Wang <[email protected]>

* Fixed bug where error detail might be empty (#478)

* Fixed bug where error detail might be empty

* Added null check to the detail string to prevent errors when detail is not set

* Second check to validate the body field

* authorization deps

* update models

* refactoring the metadata route

* include in main

* mongoout pattern

* black

* see if this new query pattern works

* metadata datasets

* finish metadata dataset and metadata file

* remove _beanie database

* codegen

* new pattern of matching id

* fix typo

* get/post works

* more fixes

* fix deleting endpoint

* fix patch endpoint

* fix put metadata

* try max's style to minimize merge conflict

---------

Co-authored-by: toddn <[email protected]>
Co-authored-by: Max Burnette <[email protected]>
Co-authored-by: Aruna Parameswaran <[email protected]>
Co-authored-by: Todd Nicholson <[email protected]>
* import container (#462)

* 446 gui to manage api keys (#465)

* add new routes placeholder

* add list and delete endpoint; inline docs

* codegen and pytest

* ugly ui?

* onstart clear user keys

* delete works but pytest doesn't work yet

* pytest all works

* codegen

* redux

* reducer and types

* write the table

* correctly wire in the apikey and error handling

* wire in the delete modal of apikeys

* wire in the creation api key

* everything working in the gui

* formatting

---------

Co-authored-by: toddn <[email protected]>

* Sharing tab cleanup (#430)

* fix bug where users not being fetched

* simplifying role query pt 1

* refactor tables and API calls

* cleanup

* start moving GroupAndRole to separate table

* add expanding sub table

* remove AddGroup buttons for now

* formatting

* codegen

* add response model

* codegen

* remove container

* fix bug with Roles return object and autocomplete on groups

* codegen

* Fix reload bug (#451)

* 461 fix library version in pipfile (#468)

* fix pipfile version

* regenerate the piplock file

* 443 frontend need to display more verbose backend error (#458)

* Updated frontend error message to be more verbose

* Backend returns verbose logs, frontend displays it as generic messages depending on the HTTP status code

* Updated the error message logic to include original backend logs wherever possible

* Fixed report button issue

* Rootcause: The onClick event for the report button has a semantic error, which is causing the issue reason string to be replaced with an object

* Also added encode for the reason

* Fixing issue with error message

* Revert "Updated frontend error message to be more verbose"

This reverts commit 7d230d3.

* Fixing issue with error message

* 469 create profile page (#471)

* profile page exists

* new route for user profile
profile page includes layout

* codegen new route for get current user profile

* we now get the profile, but nothing shows yet

* page has fake data

* we see the profile now

* formatting

* Implemented role delete in sharing tab (#472)

* Tested by deleting a user, group. Verified entry is removed upon refresh

* Show Creator on Group Page (#428)

* the owner is visible, and we cannot change the owner in the table

* showing group creator on top

* creator link is wrong, need to fix

* bold text for word 'creator'

* using more conditionals to reduce duplicate code

* missing modal added
creator name matches other names

---------

Co-authored-by: Chen Wang <[email protected]>

* Fixed bug where error detail might be empty (#478)

* Fixed bug where error detail might be empty

* Added null check to the detail string to prevent errors when detail is not set

* Second check to validate the body field

* filter the option without group owner

* filter group owner out

* Made the updaterole function async, and added a call to fetch roles to refresh the list of roles in state

* Updated remove role logic to automatically refresh the roles list

* Executed eslint

* stub for feeds

* add basic Feed support

* various updates

* introduce listener views

* update config model

* More updates to metadata models

* Update datasets.py

* update metadata usage

* formatting

* replace db["datasets"]

* Update metadata.py

* ObjectID & response cleanups

* syntax fix

* author -> creator

* formatting

* consistent syntax

* fix init of listener views

---------

Co-authored-by: Chen Wang <[email protected]>
Co-authored-by: toddn <[email protected]>
Co-authored-by: Aruna Parameswaran <[email protected]>
Co-authored-by: Todd Nicholson <[email protected]>
* users fixed to use beanie

* methods throw exceptions
groups

* token uses BaseModel and Document
UserDB used in authentication routes

* user_out uses dict

* checking against Max's branch to avoid conflicts

* matching example from Chen on new db get and find

* black formatting

* rename methods

* returning None, not sure why

* routes tested for users
still working on groups

* fixing groups
need to use different replace

* fix key save

* more key deletion

* fixing replace

* consistent syntax, regex fixes

* simplify syntax

---------

Co-authored-by: Max Burnette <[email protected]>
* import container (#462)

* 446 gui to manage api keys (#465)

* add new routes placeholder

* add list and delete endpoint; inline docs

* codegen and pytest

* ugly ui?

* onstart clear user keys

* delete works but pytest doesn't work yet

* pytest all works

* codegen

* redux

* reducer and types

* write the table

* correctly wire in the apikey and error handling

* wire in the delete modal of apikeys

* wire in the creation api key

* everything working in the gui

* formatting

---------

Co-authored-by: toddn <[email protected]>

* Sharing tab cleanup (#430)

* fix bug where users not being fetched

* simplifying role query pt 1

* refactor tables and API calls

* cleanup

* start moving GroupAndRole to separate table

* add expanding sub table

* remove AddGroup buttons for now

* formatting

* codegen

* add response model

* codegen

* remove container

* fix bug with Roles return object and autocomplete on groups

* codegen

* Fix reload bug (#451)

* 461 fix library version in pipfile (#468)

* fix pipfile version

* regenerate the piplock file

* 443 frontend need to display more verbose backend error (#458)

* Updated frontend error message to be more verbose

* Backend returns verbose logs, frontend displays it as generic messages depending on the HTTP status code

* Updated the error message logic to include original backend logs wherever possible

* Fixed report button issue

* Rootcause: The onClick event for the report button has a semantic error, which is causing the issue reason string to be replaced with an object

* Also added encode for the reason

* Fixing issue with error message

* Revert "Updated frontend error message to be more verbose"

This reverts commit 7d230d3.

* Fixing issue with error message

* 469 create profile page (#471)

* profile page exists

* new route for user profile
profile page includes layout

* codegen new route for get current user profile

* we now get the profile, but nothing shows yet

* page has fake data

* we see the profile now

* formatting

* Implemented role delete in sharing tab (#472)

* Tested by deleting a user, group. Verified entry is removed upon refresh

* Show Creator on Group Page (#428)

* the owner is visible, and we cannot change the owner in the table

* showing group creator on top

* creator link is wrong, need to fix

* bold text for word 'creator'

* using more conditionals to reduce duplicate code

* missing modal added
creator name matches other names

---------

Co-authored-by: Chen Wang <[email protected]>

* Fixed bug where error detail might be empty (#478)

* Fixed bug where error detail might be empty

* Added null check to the detail string to prevent errors when detail is not set

* Second check to validate the body field

* filter the option without group owner

* filter group owner out

* Made the updaterole function async, and added a call to fetch roles to refresh the list of roles in state

* Updated remove role logic to automatically refresh the roles list

* Executed eslint

* remove _beanie

* wire in folder db

* download folder

* refactored everything in file/folder

* reformat

* missed a spot

* codegen

* forget to add FileVersionDB

* add await

* fix more merge conflict

* duplicate

* fix inc

* black fromat

* codegen

* fix inconsistency

* black

* fix frontend author/creator

* fix detail

* fix some of the async bug

* download works

* init & use TokenDB everywhere

* fix files/submit endpoint

* remove manual index creation

* fix extractor submission

---------

Co-authored-by: toddn <[email protected]>
Co-authored-by: Max Burnette <[email protected]>
Co-authored-by: Aruna Parameswaran <[email protected]>
Co-authored-by: Todd Nicholson <[email protected]>
* fixing mongomodel

* deleting unused mongomodel
* revert id

* remove unused import

* codegen

* fix user token

* remove all the mentioning of db

* fix more inconsistencies

* fix more to_mongo

* add error db model

* remove all the to mongo

* force list of dataset out object to have .dict so id can show correctly

* black formatting

---------

Co-authored-by: Max Burnette <[email protected]>
* remove PydanticObjectId

* begin converting IDs

* major updates to db calls, id support

* replace Outs with dict returns

* add missing awaits
* fix api key and dataset tests

* test fixes for extractors

* fix job view definitions

* minor fixes

* fix files, folders, listener tests

* fix remaining tests
@lmarini
Copy link
Member Author

lmarini commented May 19, 2023

I can't get metadata_files.get_file_metadata() to work because of the way we are creating the variable arguments query. Taking a break from it but didn't want to forget so putting it here.

@lmarini
Copy link
Member Author

lmarini commented May 19, 2023

Edit medata fails with

    query.append(MetadataDB.definition == definition)
AttributeError: 'dict' object has no attribute 'append'```

Looks like we are mixing query definitions methods, line 196.

max-zilla added 3 commits May 23, 2023 09:07
* make heartbeat listener async

* update heartbeat listener

* update message_listener to async

* fix typo

* update Dockerfiles

* update Dockerfiles
* make heartbeat listener async

* update heartbeat listener

* update message_listener to async

* fix typo

* update Dockerfiles

* update Dockerfiles

* WIP

* clean up dockerfiles

* remove unused config

* revert config to localhost

* update RabbitMQ connection info for services

* revert localhost IP change for docker
@max-zilla max-zilla requested a review from tcnichol June 1, 2023 14:05
@max-zilla max-zilla marked this pull request as ready for review June 1, 2023 17:48
@max-zilla max-zilla self-requested a review as a code owner June 1, 2023 17:48
@ddey2
Copy link
Member

ddey2 commented Jun 5, 2023

Seeing the following error during extraction and viewing User metadata and Extraction Metadata tab
Screenshot 2023-06-05 at 6 54 53 AM
Screenshot 2023-06-05 at 6 47 12 AM
Screenshot 2023-06-05 at 6 47 23 AM

ddey2 and others added 5 commits June 6, 2023 09:42
* various metadata fixes

* try/except on ES update calls

* Fix search, remove console logs

* use insert over save

* properly await listener insert
GroupDB.creator == user_id,
GroupDB.users.user.email == user_id,
),
sort=("created", DESCENDING),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might also see sort=(-GroupDB.created)

@max-zilla max-zilla merged commit 6326876 into main Jun 13, 2023
@max-zilla max-zilla deleted the beanie branch June 13, 2023 20:27
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.

Consider Beanie as ODM for MongoDB and Pydantic

6 participants