Skip to content

Commit

Permalink
Remove unwanted (?!) keys in output jbrowse config
Browse files Browse the repository at this point in the history
Occasionally `jbrowse get-config` outputs `_id` and `__v` keys:

```
gitpod /workspace/apollo3-annotation/jbrowse_data (create_script) $ apollo jbrowse get-config
{
  "configuration": {
    "theme": {
      "palette": {
....
  },
  "_id": {},
  "__v": 0
}
```

Which result in:

```
 apollo jbrowse set-config config.json
    Error: Failed to add JBrowse configuration — 422 Unprocessable Entity ({"message":"ValidationError: _id: Cast to ObjectId failed for value \"{}\" (type Object) at path \"_id\" because of
    \"BSONTypeError\"","error":"Unprocessable Entity","statusCode":422})
```
  • Loading branch information
dariober committed Oct 21, 2024
1 parent 7cc023b commit 3565823
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/apollo-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ npm install -g @apollo-annotation/cli
$ apollo COMMAND
running command...
$ apollo (--version)
@apollo-annotation/cli/0.1.20 linux-x64 node-v20.17.0
@apollo-annotation/cli/0.1.20 linux-x64 node-v20.13.0
$ apollo --help [COMMAND]
USAGE
$ apollo COMMAND
Expand Down
4 changes: 4 additions & 0 deletions packages/apollo-cli/src/commands/jbrowse/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export default class GetConfig extends BaseCommand<typeof GetConfig> {
}

const json = (await response.json()) as object
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete json['_id' as keyof typeof json]
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete json['__v' as keyof typeof json]
this.log(JSON.stringify(json, null, 2))
}
}
26 changes: 26 additions & 0 deletions packages/apollo-cli/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ def testLogin(self):
) # NB: "Timeout" comes from utils.py, not Apollo
# This should be ok
shell(f"{apollo} login {P} --force", timeout=5, strict=True)

def testFileUpload(self):
p = shell(f"{apollo} file upload {P} -i test_data/tiny.fasta")
out = json.loads(p.stdout)
Expand Down Expand Up @@ -1219,6 +1220,31 @@ def testDeleteFile(self):
out = json.loads(p.stdout)
self.assertEqual(0, len(out))

def testGetAndSetJbrowseConfig(self):
shell(f"{apollo} jbrowse get-config {P} > tmp.jb.json")
shell(
"""
jq '.configuration += {
"ApolloPlugin": {
"featureTypeOntology": "Some Ontology Name",
"ontologies": [
{
"name": "Some Ontology Name",
"version": "full",
"source": {
"uri": "http://localhost:9000/test_data/so-v3.1.json",
"locationType": "UriLocation"
}
}
]
}
}' tmp.jb.json > tmp.jb2.json
"""
)
shell(f"{apollo} jbrowse set-config {P} tmp.jb2.json")
os.remove("tmp.jb.json")
os.remove("tmp.jb2.json")


if __name__ == "__main__":
unittest.main()

0 comments on commit 3565823

Please sign in to comment.