-
Notifications
You must be signed in to change notification settings - Fork 22
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
First attempt export as ELN
1913b23
to
bc808fe
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1371 +/- ##
==========================================
- Coverage 80.10% 79.98% -0.12%
==========================================
Files 70 74 +4
Lines 4755 4962 +207
==========================================
+ Hits 3809 3969 +160
- Misses 946 993 +47
🚀 New features to boost your workflow:
|
datalab
|
Project |
datalab
|
Branch Review |
bc/export-ELN
|
Run status |
|
Run duration | 07m 39s |
Commit |
|
Committer | Ben Charmes |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
0
|
|
0
|
|
336
|
View all changes introduced in this branch ↗︎ |
3030f86
to
f83c6df
Compare
Use APScheduler Use APScheduler Use APScheduler Use APScheduler Use APScheduler Use APScheduler
748ed5c
to
c85a1bf
Compare
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
Closes #1332 & #1046
Implements a new API endpoint and background process to export full collections as .eln files