Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(x/data/v2/client)!: add generate-iri command #2190

Merged
merged 8 commits into from
Apr 9, 2024

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Apr 2, 2024

Description

Closes: #XXXX

Testing instructions:

  • try generate-iri with a .jsonld file
  • try generate-iri with another non RDF file
  • try convert-iri-to-hash with some IRI
  • try convert-hash-to-iri with some hash

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@aaronc aaronc marked this pull request as ready for review April 3, 2024 18:37
Copy link
Member

@clevinson clevinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I've gone ahead and completed the following tests:

  • try file-iri with a .jsonld file
  • try file-iri with another non RDF file
  • try convert-iri-to-hash with some IRI
  • try convert-hash-to-iri with some hash

Two questions / suggestions I have:

  1. Is there another command name you were considering besides regen q data file-iri? It's not the most clear IMO, but I'm not sure if I could think of a better one... When initially thinking about this, part of me wanted these utility CLI functions to be outside of the query subcommand entirely, as they aren't actually querying for any on-chain data. Something like regen utils iri-from-file or regen iri-from-file or regen utils file-to-iri ?
  2. when running regen q data convert-iri-to-hash it only provides output as as YAML/text. can you add the --output flag so that one can set output as JSON? This would make it easier to convert back to an IRI via the corresponding convert-hash-to-iri function?

@aaronc
Copy link
Member Author

aaronc commented Apr 3, 2024

The command already has a -o option.

@clevinson
Copy link
Member

clevinson commented Apr 3, 2024

With other regen q data subcommands there is indeed an -o / --output option, but not for any of these utility commands that I tested.

See below:

$ regen q data resolver --help
Query a resolver by its unique identifier.

Usage:
  regen query data resolver [id] [flags]

Examples:
  regen q data resolver 1

Flags:
      --grpc-addr string   the gRPC endpoint to use for this chain
      --grpc-insecure      allow gRPC over insecure channels, if not TLS the server must use TLS
      --height int         Use a specific height to query state at (this can error if the node is pruning state)
  -h, --help               help for resolver
      --node string        <host>:<port> to Tendermint RPC interface for this chain (default "tcp://localhost:26657")
  -o, --output string      Output format (text|json) (default "text")

Global Flags:
      --chain-id string     The network chain ID
      --home string         directory for config and data (default "/Users/cory/.regen")
      --log_format string   The logging format (json|plain) (default "plain")
      --log_level string    The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
      --trace               print out full stack trace on errors

versus

$ regen q data convert-iri-to-hash --help
Convert an IRI to a ContentHash.

Usage:
  regen query data convert-iri-to-hash [iri] [flags]

Examples:
  regen q data convert-iri-to-hash regen:13toVfvC2YxrrfSXWB5h2BGHiXZURsKxWUz72uDRDSPMCrYPguGUXSC.rdf

Flags:
  -h, --help   help for convert-iri-to-hash

Global Flags:
      --chain-id string     The network chain ID
      --home string         directory for config and data (default "/Users/cory/.regen")
      --log_format string   The logging format (json|plain) (default "plain")
      --log_level string    The logging level (trace|debug|info|warn|error|fatal|panic) (default "info")
      --trace               print out full stack trace on errors

@aaronc
Copy link
Member Author

aaronc commented Apr 3, 2024

Oh, that's a regression. Try now

@aaronc
Copy link
Member Author

aaronc commented Apr 3, 2024

Also we can call this something besides file-iri if you have suggestions, but I'd rather not introduce a new utils command set because then I have to go up to the top level command and add a new command tree and that spreads data module related stuff over more sub-commands. I already find it somewhat counterintuitive that there is tx data and query data as opposed to data tx and data query. I'd prefer not to add a third layer of complexity

@clevinson
Copy link
Member

clevinson commented Apr 4, 2024

Keeping it all within query commands sounds good 👍. I do think it'd be nice then to update the description of data query commands (e.g. the display text for regen q data --help) to state that it also contains data module utility functions. Can you do that?

Currently it just says "Query commands for the data module." Which to me implies that all sub commands query the blockchain.

As for names of the file subcommand, I prefer something that describes the relation btw file & iri. So either file-to-iri, iri-from-file, get-iri-from-file, generate-iri. With a slight preference amongst these for generate-iri (which is in line with our language in regen-web/iri-gen package), or iri-from-file.

@aaronc
Copy link
Member Author

aaronc commented Apr 4, 2024

Can you just pick a name and I'll update the PR?

@clevinson
Copy link
Member

Let's do generate-iri

@aaronc aaronc changed the title feat(x/data/client): add file-iri command feat(x/data/client): add generate-iri command Apr 9, 2024
@aaronc
Copy link
Member Author

aaronc commented Apr 9, 2024

Let's do generate-iri

Updated

@aaronc aaronc changed the title feat(x/data/client): add generate-iri command feat(x/data/v2/client): add generate-iri command Apr 9, 2024
Copy link
Member

@clevinson clevinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@aaronc aaronc changed the title feat(x/data/v2/client): add generate-iri command feat(x/data/v2/client)!: add generate-iri command Apr 9, 2024
@aaronc aaronc merged commit 7ca7808 into release/v5.1.x Apr 9, 2024
27 checks passed
@aaronc aaronc deleted the aaronc/data-commands branch April 9, 2024 23:25
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