File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Rewrite (update) all manifest files.
3
+
4
+ This script runs the `write_manifest_files()` function on all dandiset versions, allowing us to
5
+ rewrite the manifest files. We needed to run this as a one-time script when we moved from our
6
+ development AWS account to the AWS Open Data account, thus changing the AWS S3 bucket our data is
7
+ stored in. Currently the asset manifest files (.jsonld and .yaml) contain the name of the bucket, so
8
+ this became out of date when we copied the data over and changed the bucket. This script runs an
9
+ update on the manifest files, fixing the bucket referenced the asset manifest files.
10
+
11
+ We are doing this using the heroku CLI to connect to our database and then write_manifest_files()
12
+
13
+ Usage:
14
+ # Open an interactive bash shell inside the heroku dyno for the given app
15
+ heroku run -a <heroku_app_name> bash
16
+
17
+ # Open a Django shell
18
+ ./manage.py shell_plus
19
+ # Run the script by copying and pasting the code
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import click
25
+
26
+ from dandiapi .api .models import Version
27
+ from dandiapi .api .tasks import write_manifest_files
28
+
29
+ all_versions = Version .objects .values_list ('id' , flat = True )
30
+ all_versions_count = all_versions .count ()
31
+ click .echo (f'version count is { all_versions_count } ' )
32
+
33
+ if all_versions_count > 0 :
34
+ for version_id in all_versions .iterator ():
35
+ write_manifest_files .delay (version_id )
36
+ else :
37
+ click .echo ('Found no versions.' )
You can’t perform that action at this time.
0 commit comments