Skip to content

Commit

Permalink
fix silliness around dts manifest mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Nov 14, 2024
1 parent ccf1761 commit 4f6044d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ gzip, bzip2, md5sum, head, tail, wc

in the docker container all of these should be available

## Updating importer mapping types
The types returned by the `importer_mappings` endpoint (see [Get Importer Mappings](#get-importer-mappings) below)
are generated by the `GenerateMappings.py` script here: `staging_service/autodetect/GenerateMappings.py`.
Running this script will build the `supported_apps_w_extensions.json` file that should be placed in the
`deployment/conf` directory.

To add new mappings, update the `GenerateMappings.py` script. New file types and object types should be added
to the `staging_service.autodetect.Mappings` module and included from there. See `GenerateMappings.py`
docstrings for more details.

## API

all paths should be specified treating the user's home directory as root
Expand Down
28 changes: 14 additions & 14 deletions deployment/conf/supported_apps_w_extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1102,34 +1102,34 @@
}
]
},
"smbl": {
"json": {
"file_ext_type": [
"SBML"
"JSON"
],
"mappings": [
{
"id": "fba_model",
"title": "FBA Model",
"id": "import_specification",
"title": "Import Specification",
"app_weight": 1
},
{
"id": "escher_map",
"title": "EscherMap",
"app_weight": 1
}
]
},
"json": {
"smbl": {
"file_ext_type": [
"JSON"
"SBML"
],
"mappings": [
{
"id": "escher_map",
"title": "EscherMap",
"app_weight": 1
},
{
"id": "import_specification",
"title": "Import Specification",
"id": "fba_model",
"title": "FBA Model",
"app_weight": 1
}
]
}
}
}
}
4 changes: 2 additions & 2 deletions staging_service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from .app_error_formatter import format_import_spec_errors
from .auth2Client import KBaseAuth2
from .autodetect.Mappings import CSV, EXCEL, TSV, DTS_MANIFEST
from .autodetect.Mappings import CSV, EXCEL, TSV, JSON
from .AutoDetectUtils import AutoDetectUtils
from .globus import assert_globusid_exists, is_globusid
from .import_specifications.file_parser import (
Expand Down Expand Up @@ -48,7 +48,7 @@
CSV: parse_csv,
TSV: parse_tsv,
EXCEL: parse_excel,
DTS_MANIFEST: parse_dts_manifest,
JSON: parse_dts_manifest,
}

_IMPSPEC_FILE_TO_WRITER = {
Expand Down
11 changes: 10 additions & 1 deletion staging_service/autodetect/GenerateMappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
* Note: We should serve the generated content from memory
* Note: This doesn't handle if we want to have different output types based on file extensions
feeding into the same app
Adding new file types and app ids:
* file types and app ids should be added to staging_service.autodetect.Mappings
* file types should be all upper-case and represent the file suffix.
* app ids should be in snake_case, and represent either an object import type, or some
internal application to be run on selection (i.e. decompress or import specification).
* app ids that map to actual object import maps should match the app ids in the narrative
interface configuration here:
https://github.com/kbase/narrative/blob/main/kbase-extension/static/kbase/config/staging_upload.json
"""

from collections import defaultdict
Expand Down Expand Up @@ -120,7 +129,7 @@
fba_model_id,
import_specification,
]
file_format_to_app_mapping[JSON] = [escher_map_id]
file_format_to_app_mapping[JSON] = [escher_map_id, import_specification]
file_format_to_app_mapping[SBML] = [fba_model_id]

app_id_to_extensions = defaultdict(list)
Expand Down
4 changes: 0 additions & 4 deletions staging_service/autodetect/Mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
EXCEL = "EXCEL"
ZIP = "CompressedFileFormatArchive"

# Data Transfer Service Manifest format (which is a specific JSON format)
DTS_MANIFEST = "JSON"

# BIOINFORMATICS FORMATS
FASTA = "FASTA"
FASTQ = "FASTQ"
Expand Down Expand Up @@ -103,7 +100,6 @@ def _add_gzip(extension_list):
# ],
TSV: ["tsv"], # See Note 1 below
CSV: ["csv"], # See Note 1 below,
DTS_MANIFEST: ["json"],
JSON: ["json"],
EXCEL: ["xls", "xlsx"], # See Note 1 below
ZIP: ["zip", "tar", "tgz", "tar.gz", "7z", "gz", "gzip", "rar"],
Expand Down

0 comments on commit 4f6044d

Please sign in to comment.