-
Notifications
You must be signed in to change notification settings - Fork 8
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
First pass at new command line API #63
Conversation
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.
Like the --scheduler
option, will be easy to add others
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.
A major concern I have regarding the CLI API, ultimately of concern to the PR but perhaps not its current state which is more focused on valid arguments and their scope seemingly at present, which looks good to me, is the machine parsability and the human readability of the possible outputs.
Namely, I strongly suggest that we ensure that for whatever information that a user can request to output, whether a single figure (e.g. with this new suggested --quiet
option which I like) or multiple statistics (e.g. run time plus carbon estimate, etc.), there is a means to provide that in a way which could be parsed by code, particularly as a recognised data serialisation format such as JSON or YAML or CSV, etc. (JSON seems most sensible without my having thought much about the choices, but we can discuss this).
We could even provide CLI options so that different formats can be output, e.g. JSON, CSV, since on the code side it is trivial to convert between those once we have constructed a standard format. Which makes me think that the --scheduler
option shouldn't control the format, rather we have separate CLI option(s) to set that, e.g. -j
for JSON and -y
for YAML, or we can have an option for --format
and custom formats for a given scheduler could be set as values, e.g. --format=json
, --format=at
, or similar.
If a --scheduler
gets set, it could (and I think this would be useful) automatically set the --format
to the appropriate format, but also pass, e.g. pipe, to the relevant scheduler. And for optimum human readability, we can have a dedicated option such as --format=simple
or something.
I realise we generally we only be outputting a small number of pieces of information, but regardless having a standard output format means people can extract or forward that information as they wish.
So in short I am currently thinking we have a separate --format
option to --schedule(r)
option to initiate the actual scheduling, in which case we should allow the --
option so arguments can be passed onto the schedule rather than to CATS.
I also wonder if CATS would benefit from a separate formatting option to cover the datetime format supplied for run time and any other datetimes, since that piece of data in itself can be specified in a myriad of different ways, inside the overall data format of the output.
I like the idea of a |
@andreww is this ready to merge? |
@abhidg - no, afraid not. Thus far it's just changing the documentation to describe what we want to happen (and that still needs further update following @sadielbartholomew's suggestion). Actually writing the code to make cats behave like this is still something that needs doing (and I don't think we should merge the documentation until it describes the code). |
Only changes the documentation. For discussion.
Adds --format option for output formatting, currently only JSON is supported Change sys.stderr.write to logging calls Fixes: GreenScheduler#67
Adds a -c (--command) parameter to pass the command to the scheduler Fixes: GreenScheduler#53
d562922
to
27a0bba
Compare
I've just had a play around with this and have a few questions about the way it now behaves:
|
They control different things:
I am good either way. One reasoning for keeping it optional is if the user wants to use CATS just to get the optimal time and not schedule.
Will update them once the CLI is locked in!
Matter of taste. I am fine either way. We could also default to
Nothing accepts the JSON format, it is more for piping to something like ls | at -t $(cats --loc OX1 -d 5 --dateformat='%Y%m%d%H%M' --format=json | jq -r '.carbonIntensityOptimal.start' |
92b9fc2
to
d6dec68
Compare
d6dec68
to
f6c8d9c
Compare
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.
I like this! Thanks for the work.
Only changes the documentation. For discussion.
Other things to do: