|
| 1 | +# Manifest CSV |
| 2 | + |
| 3 | +The manifest is a CSV file with file locations and metadata used to bulk upload and download files in Synapse. It is the standard manifest format used by `Project.sync_from_synapse`, `Project.sync_to_synapse`, `Folder.sync_from_synapse`, `Folder.sync_to_synapse`, the Synapse UI download cart, and the `synapse get-download-list` CLI command. |
| 4 | + |
| 5 | +!!! note "Replaces legacy TSV manifest" |
| 6 | + This CSV manifest replaces the legacy TSV manifest (`SYNAPSE_METADATA_MANIFEST.tsv`) produced by [synapseutils.syncFromSynapse][]. The `syncFromSynapse` and `syncToSynapse` utility functions are deprecated and will be removed in v5.0.0. Use `Project.sync_from_synapse` / `Folder.sync_from_synapse` and `Project.sync_to_synapse` / `Folder.sync_to_synapse` instead. See the [legacy TSV manifest documentation](manifest_tsv.md) for details on the old format. |
| 7 | + |
| 8 | +## Manifest file format |
| 9 | + |
| 10 | +The format of the manifest file is a comma-separated values (CSV) file with one row per file and columns describing the file. The minimum required columns for uploading are **path** and **parentId**, where `path` is the local file path and `parentId` is the Synapse ID of the project or folder where the file is uploaded to. |
| 11 | + |
| 12 | +Values that contain commas are automatically quoted (e.g., `"hello, world"`). This is handled by the standard CSV format using `QUOTE_MINIMAL` quoting. |
| 13 | + |
| 14 | +### Required fields for upload |
| 15 | + |
| 16 | +| Field | Meaning | Example | |
| 17 | +|----------|----------------------------|-------------------------| |
| 18 | +| path | local file path or URL | /path/to/local/file.txt | |
| 19 | +| parentId | Synapse ID of parent | syn1235 | |
| 20 | + |
| 21 | +### Standard fields |
| 22 | + |
| 23 | +These columns are recognized by `sync_to_synapse` and have specific meaning. Any of these columns may be present in the manifest but only `path` and `parentId` are required for upload. |
| 24 | + |
| 25 | +| Field | Meaning | Example | |
| 26 | +|---------------------|--------------------------------------------|----------------------------------------------| |
| 27 | +| path | local file path or URL | /path/to/local/file.txt | |
| 28 | +| parentId | Synapse ID of parent container | syn1235 | |
| 29 | +| ID | Synapse entity ID | syn2345 | |
| 30 | +| name | name of file in Synapse | Example_file | |
| 31 | +| synapseStore | whether to upload the file | True | |
| 32 | +| contentType | content type of file to overload defaults | text/html | |
| 33 | +| forceVersion | whether to update version | False | |
| 34 | +| activityName | name of activity in provenance | Ran normalization | |
| 35 | +| activityDescription | text description of what was done | Ran algorithm xyz with parameters... | |
| 36 | +| used | list of items used to generate file | syn1235;/path/to_local/file.txt | |
| 37 | +| executed | list of items executed | https://github.org/;/path/to_local/code.py | |
| 38 | + |
| 39 | +### Metadata fields (ignored during upload) |
| 40 | + |
| 41 | +These columns are present in manifests generated by the Synapse UI download cart and `synapse get-download-list` CLI. They are ignored by `sync_to_synapse` and are **not** treated as annotations. |
| 42 | + |
| 43 | +| Field | Meaning | |
| 44 | +|-------------------|-------------------------------| |
| 45 | +| error | any error in downloading file | |
| 46 | +| versionNumber | version of the file | |
| 47 | +| dataFileSizeBites | size of the file in bytes | |
| 48 | +| createdBy | user who created the file | |
| 49 | +| createdOn | date the file was created | |
| 50 | +| modifiedBy | user who last modified | |
| 51 | +| modifiedOn | date last modified | |
| 52 | +| synapseURL | URL to the file in Synapse | |
| 53 | +| dataFileMD5Hex | MD5 hash of the file | |
| 54 | + |
| 55 | +### Annotations |
| 56 | + |
| 57 | +Any columns that are not in the standard or metadata fields described above will be interpreted as annotations of the file. |
| 58 | + |
| 59 | +Adding annotations to each row: |
| 60 | + |
| 61 | +| path | parentId | annot1 | annot2 | annot3 | annot4 | annot5 | |
| 62 | +| --- | --- | --- | --- | --- | --- | --- | |
| 63 | +| /path/file1.txt | syn1243 | bar | 3.1415 | "aaaa, bbbb" | "[14,27,30]" | "Annotation, with a comma" | |
| 64 | +| /path/file2.txt | syn12433 | baz | 2.71 | value_1 | "[1,2,3]" | test 123 | |
| 65 | +| /path/file3.txt | syn12455 | zzz | 3.52 | value_3 | "[42,56,77]" | a single annotation | |
| 66 | + |
| 67 | +#### Multiple values of annotations per key |
| 68 | + |
| 69 | +Using multiple values for a single annotation should be used sparingly as it makes it more |
| 70 | +difficult for you to manage the data. However, it is supported. |
| 71 | + |
| 72 | +**Annotations can be comma `,` separated lists surrounded by brackets `[]`.** |
| 73 | + |
| 74 | +Because the manifest is a CSV file, multi-value annotations that contain commas are automatically quoted. For example, `[a,b,c]` will appear in the CSV as `"[a,b,c]"`. |
| 75 | + |
| 76 | +This is an annotation with 3 values: |
| 77 | + |
| 78 | +| path | parentId | annot1 | |
| 79 | +|-----------------|----------|--------------| |
| 80 | +| /path/file1.txt | syn1243 | "[a,b,c]" | |
| 81 | + |
| 82 | +This is an annotation with 1 value (no brackets): |
| 83 | + |
| 84 | +| path | parentId | annot1 | |
| 85 | +|-----------------|----------|----------------------------| |
| 86 | +| /path/file1.txt | syn1243 | my sentence with commas | |
| 87 | + |
| 88 | +### Dates in the manifest file |
| 89 | + |
| 90 | +Dates within the manifest file will always be written as [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format in UTC without milliseconds. For example: `2023-12-20T16:55:08Z`. |
| 91 | + |
| 92 | +Dates can be written in other formats specified in ISO 8601 and they will be recognized. However, `sync_from_synapse` will always write dates in the UTC format specified above. For example, you may want to specify a datetime at a specific timezone like `2023-12-20 23:55:08-07:00` and this will be recognized as a valid datetime. |
| 93 | + |
| 94 | +## Manifest sources |
| 95 | + |
| 96 | +The CSV manifest format is shared across multiple tools: |
| 97 | + |
| 98 | +| Source | Filename | Format | |
| 99 | +|----------------------------------------------------------|---------------------------------|--------| |
| 100 | +| `Project.sync_from_synapse` / `Folder.sync_from_synapse` | manifest.csv | CSV | |
| 101 | +| Synapse UI download cart | manifest.csv | CSV | |
| 102 | +| CLI `synapse get-download-list` | manifest\_\<timestamp\>.csv | CSV | |
| 103 | + |
| 104 | +A manifest generated by any of these sources can be used as input to `sync_to_synapse`, provided the `path` column is present with valid local file paths. Manifests from the Synapse UI and CLI do not include a `path` column by default, so users must add it before uploading. |
| 105 | + |
| 106 | +### Example manifest file |
| 107 | + |
| 108 | +| path | parentId | ID | name | annot1 | annot2 | collection_date | used | executed | |
| 109 | +|-----------------|----------|---------|-----------|--------|--------|---------------------------|--------------------------|------------------------------| |
| 110 | +| /path/file1.txt | syn1243 | syn5001 | file1.txt | bar | 3.1415 | 2023-12-04T07:00:00Z | syn124;/path/file2.txt | https://github.org/foo/bar | |
| 111 | +| /path/file2.txt | syn12433 | syn5002 | file2.txt | baz | 2.71 | 2001-01-01T08:00:00Z | | https://github.org/foo/baz | |
| 112 | +| /path/file3.txt | syn12455 | syn5003 | file3.txt | zzz | 3.52 | 2023-12-04T07:00:00Z | | https://github.org/foo/zzz | |
| 113 | + |
| 114 | +## References |
| 115 | + |
| 116 | +- [Project.sync_from_synapse][synapseclient.models.Project.sync_from_synapse] |
| 117 | +- [Project.sync_to_synapse][synapseclient.models.Project.sync_to_synapse] |
| 118 | +- [Folder.sync_from_synapse][synapseclient.models.Folder.sync_from_synapse] |
| 119 | +- [Folder.sync_to_synapse][synapseclient.models.Folder.sync_to_synapse] |
| 120 | +- [Manifest TSV (legacy)](manifest_tsv.md) |
| 121 | +- [Managing custom metadata at scale](https://help.synapse.org/docs/Managing-Custom-Metadata-at-Scale.2004254976.html#ManagingCustomMetadataatScale-BatchUploadFileswithAnnotations) |
0 commit comments