Skip to content

Dump records in JSON from hop subscribe - #253

Open
jvansanten wants to merge 1 commit into
scimma:masterfrom
jvansanten:dump-avro-blobs-as-json
Open

Dump records in JSON from hop subscribe#253
jvansanten wants to merge 1 commit into
scimma:masterfrom
jvansanten:dump-avro-blobs-as-json

Conversation

@jvansanten

Copy link
Copy Markdown

Description

hop subscribe has a --json option that purports to "Request message output as raw json," but does not actually do anything. This PR causes hop subscribe to serialize the message content as JSON when the option is activated.

This is particularly useful for AvroBlob, which is otherwise not terribly legible.

Checklist

  • All new functions and classes are documented and adhere to Google doc style (3.8.3-3.8.6 of this document)
  • Add/update sphinx documentation with any relevant changes.
  • Add/update pytest-style tests in /tests, ensuring sufficient code coverage.
  • make test runs without errors.
  • make lint doesn't give any warnings.
  • make format doesn't give any code formatting suggestions.
  • make doc runs without errors and generated docs render correctly.
  • Check that CI pipeline run on this PR passes all stages.
  • Review signoff by at least one developer.

NOTE: If this PR relates to a release, open and reference an issue with the Release checklist template.

@cnweaver

Copy link
Copy Markdown
Contributor

Unfortunately, the reason this got broken is that it isn't trivial to make it work for all message models (and I forgot to remove the option from the CLI), for a few reasons: Not all message models have a content property (VOEvent, GCNTextNotice, and GCNCircular), and others can contain non-JSON-serializable types (mainly bytes, which affects both Blob and AvroBlob; the content: Union[JSONType, List[JSONType]] type annotation in the latter is alas, not correct, and I need to figure out how to correctly write down the superset of JSON types which actually applies).

This is doable with a little bit more coding, however, if one is willing to make some tradeoffs like base64 encoding bytes so that they can legally be expressed as (rather inefficient) JSON strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants