-
Notifications
You must be signed in to change notification settings - Fork 0
Seeding DB with DREAM Challenges #82
Conversation
|
@rrchai Thanks! I fixed the service issue that you reported about empty array (see Sage-Bionetworks/rocc-service#113). I'll now try to find an elegant way to fix the seeding using RxJS. |
|
Temporarily renaming this organization ID;
EDIT: No longer an issues after reverting @rrchai commit (see below). |
|
@rrchai You replaced EDIT: @rrchai I undid your last commit because it's introducing several issues. Let's discuss these issues next week so you can resubmit your changes without the issues. |
|
Removed the following organizations from challenge.json because their ID is too long (> 60 char).
|
|
@rrchai Also remove the Person objects from the Challenge object, include the fake ids instead. Please use the default parameter names like |
|
@tschaffter I have updated files:
|
|
@rrchai Can you remove the following files?
And update the remaining files so they meet the required defined in my previous comment. Ultimately we should only have the following files whose content match the ROCC schemas either based on the schemas
|
|
@rrchai @vpchung FYI Here is a nice illustration on how Lodash can be used to manipulate objects. In this example, I use Lodash omit method to remove the property |
vpchung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one design question about the future usage of Lodash.
| import { mergeMap, tap } from 'rxjs/operators'; | ||
| import { forkJoin, Observable, of } from 'rxjs'; | ||
| import { map, mapTo, mergeMap, switchMap, tap } from 'rxjs/operators'; | ||
| import { merge as _merge, omit as _omit } from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we plan on updating Lodash as newer versions come out? According to the creator, omit will be deprecated in v5 due to poor performance. We may need to rewrite the code if so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will update libraries every month to please the Dependabot God, unless the update of a given library is not trivial. I learned about the existence of @babel/plugin-proposal-object-rest-spread by following the link you shared. I don't find this approach suitable here as it depends on the order of the object properties. I decided to go with _.pick and specify the properties to keep (array). I wasn't sure about how _.pick handled an array that includes property names that are not in a given object, for example Challenge.endDate is optional. _.pick behaves nicely and acts has a filter and it will not complain if a given object does not have the property. I'm still - and always - open to alternatives that you would like to share.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the _.pick approach as well! That being said, it may become quite tedious if numerous properties are needed... do you think that could happen? If so, we could always write a util function that mimics _.omit? I came across this article here that showcases different alternatives and their performances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we still are in the early stage of development, it's likely that object properties will be updated. It's also more likely that we will add or rename properties - i.e. which will need us to update the seeding code - than removing properties from {schema} object to get {schema}CreateResponse. Also one thing that I don't like about _.pick is because its behavior that I described earlier can lead to a point where the list of properties specified is out of sync with the properties of {schema}CreateResponse.
We can throw away the pickBy option as it it too slow and doesn’t provide any benefits.
Assuming that pick has similar performance, then let's use one of the alternative proposed in the article. I just updated the code to an an omit function based on ESRest + JavaScript delete. This implementation does not allow to remove flatten paths, which should be fine for now.
rrchai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great and I tested it works! @tschaffter
@tschaffter
I pushed the codes and updated json files for seeding challenges. The followings properties still need to be tested if they work fine with current codes and latest schema.
start/endDate:they have been changed to optional in the latest schema, since some challenge has no start/end datesorganizerIds,dataProviderIds,grantIds: check if empty array,[]is accepted in the latest services, since they are required