-
Notifications
You must be signed in to change notification settings - Fork 615
Refactor cog predict
to support --json
flag
#2404
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
Conversation
This allows `cog predict` to use JSON as the input/output format which makes it more suitable for automation such as testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is excellent, nice work! Just one suggestion about the stdin ux. And I'd like some tests around inputs and outputs someday, but this looks great for now. Nice job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor comments from my side but otherwise looks good! Perhaps it could be good to add an integration test to make sure this doesn't get lost by other changes?
Thanks both, I'll fix the failing integration test and add a couple more before merging. |
This PR introduces
cog predict --json
that represents both input and output as JSON.The intention behind this PR is to provide a better interface for machines to interface with
cog predict
. Such as running automated tests. In these cases trying to parse the existing unstable output is non-trivial. Having access to the full JSON prediction makes things much easier.In order to do this correctly the PR also fixes a number of bugs with the
--output
behavior.--output ./outputs
--output
flag for lists of files. Previously if a model returned a list of files they would all beoutput.<idx>.<ext>
regardless of the --output flag.There are several ways to use
cog predict
with the--json
flag:@-
reference.The output will be the entire prediction printed to stdout by default.
The output can also be written to a file: