-
Notifications
You must be signed in to change notification settings - Fork 25
Add ELN collection export #1371
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
base: main
Are you sure you want to change the base?
Conversation
1913b23 to
bc808fe
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1371 +/- ##
==========================================
- Coverage 80.10% 79.95% -0.15%
==========================================
Files 70 74 +4
Lines 4759 4965 +206
==========================================
+ Hits 3812 3970 +158
- Misses 947 995 +48
🚀 New features to boost your workflow:
|
datalab
|
||||||||||||||||||||||||||||
| Project |
datalab
|
| Branch Review |
bc/export-ELN
|
| Run status |
|
| Run duration | 07m 35s |
| Commit |
|
| Committer | Ben Charmes |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
336
|
| View all changes introduced in this branch ↗︎ | |
748ed5c to
c85a1bf
Compare
ml-evs
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.
This looks fantastic, thanks @BenjaminCharmes!
Just writing a couple of points here that we can discuss:
- configuring amount of resources APScheduler is allowed to use
- using pydantic models rather than direct database queries to create items etc.
- a few bits of permissions we need to be careful with
| collection_exists = flask_mongo.db.collections.find_one({"collection_id": collection_id}) | ||
| if not collection_exists: | ||
| return jsonify({"status": "error", "message": "Collection not found"}), 404 | ||
|
|
||
| collection_with_perms = flask_mongo.db.collections.find_one( | ||
| {"collection_id": collection_id, **get_default_permissions(user_only=True)} | ||
| ) | ||
| if not collection_with_perms: | ||
| return jsonify({"status": "error", "message": "Access denied"}), 403 |
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.
| collection_exists = flask_mongo.db.collections.find_one({"collection_id": collection_id}) | |
| if not collection_exists: | |
| return jsonify({"status": "error", "message": "Collection not found"}), 404 | |
| collection_with_perms = flask_mongo.db.collections.find_one( | |
| {"collection_id": collection_id, **get_default_permissions(user_only=True)} | |
| ) | |
| if not collection_with_perms: | |
| return jsonify({"status": "error", "message": "Access denied"}), 403 | |
| collection_with_perms = flask_mongo.db.collections.find_one( | |
| {"collection_id": collection_id, **get_default_permissions(user_only=True)} | |
| ) | |
| if not collection_with_perms: | |
| return jsonify({"status": "error", "message": "Collection not found"}), 404 |
Better not to leak IDs that exist but the user does not have permission for, so just treat missing ID as 404
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.
Can probably also set user_only=False
| source_path = Path(file_data["location"]) | ||
| if source_path.exists(): | ||
| dest_file = item_folder / file_data["name"] | ||
| shutil.copy2(source_path, dest_file) |
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.
Somehow the actual raw data files are not making it into the .eln file when I try to export them
ml-evs
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.
Thanks @BenjaminCharmes -- will test locally then merge.
Potential next steps:
- adding the same button for 1 sample
- building on 1, "Export" button that opens a modal for a sample, where the user can export a graph of related samples, and potentially automatically create a collection for it
First attempt export as ELN
Use APScheduler Use APScheduler Use APScheduler Use APScheduler Use APScheduler Use APScheduler
Closes #1332 & #1046
Implements a new API endpoint and background process to export full collections as .eln files