floyd-cli icon indicating copy to clipboard operation
floyd-cli copied to clipboard

Can commands return raw output instead of table

Open rmdort opened this issue 7 years ago • 3 comments

Can floyd commands return raw JSON output instead of the table ? Can we have an option for this?

floyd info job_id --raw

rmdort avatar Aug 01 '17 05:08 rmdort

This sounds useful. Feel free to send a PR!

narenst avatar Aug 01 '17 06:08 narenst

ok noted. My plan is to add an argument raw to ExperimentClient

def get(self, id, raw):
        response = self.request("GET",
                                "{}{}".format(self.url, id))
        experiment_dict = response.json()
        if raw:
            return experiment_dict
        return Experiment.from_dict(experiment_dict)

And then add options in experiment.py

@click.option('-r', '--raw', is_flag=True, default=False, help='Returns raw JSON response')
def info(id, raw)
    experiment = ExperimentClient().get(id, raw)

What do u think?

rmdort avatar Aug 01 '17 06:08 rmdort

Thanks for the offer! Can you just change the option as "--format". It can take two values "default" and "json" (default value is "default").

Also, it would be better if the change is in the info method. Once you get the experiment object, you can return the json that by calling a to_dict() method on the expt (this method needs to be added as well).

narenst avatar Aug 01 '17 19:08 narenst