-
Notifications
You must be signed in to change notification settings - Fork 36
Improve CollectionRelationship uploads in the WorkBench #3240
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
Conversation
Because this table is required for Collection Relationship and it resolves the left side and right side collections through the RelType name. This makes it so that only the available/valid names appear in the Workbench when uploading Collection Relationships
As a property of any 'uploadTable' in the upload plan, the following can be added to manually set the desired collection to upload records into for that column 'overrideScope' : { 'collection' : <COLLECTION_ID>} where <COLLECTION_ID> is the id of the collection.
The only remaining thing to accomplish with this Pull Request is to have the backend automatically override the The intended behavior can also currently be accomplished by adding a manual collection override for the |
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!
So if I understood correctly, front-end doesn't need to fill out overrideScope, as back-end will do it automatically for CollectionRelatinships, but if it would be necessary, someone can manually edit the upload plan?
Also, if I enter overrideScope, then edit upload plan in the mapper and save, the overrideScope won't be preserved? Not an issue, but something to be aware of
Yes, to stay as compatible as possible with past workbenches, I made overrideScope optional in the upload plan. We will need to add it automatically on the backend for things like CollectionRelationships. And yes, if needed someone can manually edit the upload plan and tell the backend which collection to validate and upload into. With this change, some use cases might be uploading Collection Objects in multiple collections with one WorkBench dataset, or upload/validate PickLists for a separate collection, etc...
The upload plan is stored in the database. Editing and then saving the upload plan saves it to the database, so overrrideScope will be preserved. |
I like how you implemented it, but I don't think there would be that much need for this beyond CollectionRelationships - most of the time, if users want to upload into a different collection, they would just switch to that collection |
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.
The code for deferring scope looks tricky. Sorry can't comprehend it right now as I don't know well what's going on here.
If there is a way to simplify it then do it, otherwise document what the DeferedUploadPlan concept means and how it interacts with UploadPlan. Also, let's keep up the tradition of workbench have very good test coverage and add test cases for the newly added code - that will also help explain to others what's the expected behavior
This is ready to be tested. I will fix any failing tests and add comments/documentation either tonight or tomorrow, but all of the logic is in place. When testing, please make sure that right-side collection objects get uploaded/matched correctly in the rightSideCollection of the collection rel type. (Also, test to ensure that it validates and uploads with the correct collection's Catalog Number formatting). Please also do brief testing of common workbench uploads/functions, as well as for recordsets. |
I am so impressed just reading your summary and code. Excited to try this and so happy to see this!!! |
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.
Does it check for permissions when uploading into a different collection? |
Triggered by 690376b on branch refs/heads/issue-3089
I've (finally) resolved all of the failing tests. |
@chanulee1 Can you test this today? |
Collection Rel Type and the Left/Ride side Collection Objects are required, but only in the frontend (as schema overrides). Thus they are not actually required on a database level. The cell highlighting is done by checking if the SpLocaleContainerItem associated with each column of the upload is required in the database. specify7/specifyweb/workbench/upload/parsing.py Lines 60 to 71 in e96288c
Preferably, we run a Django migration which properly marks the correct fields as required in the database. However, to be thorough, we would additionally need to modify the Specify6 datamodel xml (The django fields are built from the xml). We may even Alternatively, we can make schema overrides for the backend. However, I do not like this solution because it fragments the schema even further. There would be front-end overrides, back-end overrides, and then what the value is in the database. |
I have talked with @grantfitzsimmons and we have reached a conclusion about how to approach this. If we solve the root of the problem, alongside a django migration, we would need to modify Specify's 6 Alternatively, adding schema overrides to the backend would needlessly make debugging in the future more difficult, as the schema would be split into 3 pieces (the frontend representation, backend, and database) and cost more development time in the future. The solution would be 'hacky', and not long term. For now, unless any further ideas are brought forward, it may be wise to leave this as is for now and provide documentation explaining the behavior. A proper solution-regardless of the way we go-will warrant further discussion. |
@realVinayak and @chanulee1 – can you test this when you get a chance? |
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. Right side collection object validated using right collection's catalog number format. Right side collection object is created when catalog number does not exist in right side collection. Collection Relationship uploads seem to be working well.
Triggered by c01fcd0 on branch refs/heads/issue-3089
See #4929 for an alternate implementation. The main difference is that I consider scoping completely different than binding. Instead of scoping upload plan "constantly" (which then required defer logic per-row), I scope it for every row (so defer isn't needed -- just scope). Simplifies things this way. For performance, observe that upload plan only needs to be rescoped if there are collection relationships (or any other "defer" fields). So, it checks for them when doing scoping. If not found, it is safe to cache it. Hence, the little caching mechanism in that implementation. That is, the upload plan gets scoped just once (for the first row, the next rows reuse it as long as no defer fields are found), which is the common case (most wb uses don't involve collection relationships). |
Fixes #3089
This pull request includes:
Autogenerated default forms for CollectionRelationship and CollectionRelType
Apply the proper schema overrides for CollectionRelationship and CollectionRelType.
Makes
CollectionRelType.name
a frontend-only picklist withname
as its fieldAdds the ability to override which collection a column will upload into
To accomplish this, go into the uploadplan (A video is attached detailing this process)
Find the correct relationship/table/column you want to override
As a key/value pair for an
uploadTable
, add"overrideScope" : {"collection" : COLLECTION_ID}
, where COLLECTION_ID is your desired collection to upload intoNOTE: This override should work for any table being uploaded through the WorkBench, not just CollectionRelationships
To View Upload Plan
wb_show_plan.mp4
* a video showing how to view the [DEV] Show Plan button
Collection Override Example
* an example of a collection override being applied to the
rightside
of a CollectionRelationship, with the additions marked by an orange box