-
Notifications
You must be signed in to change notification settings - Fork 279
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(client_cli): Integrating CLI API to set and retrieve parameters. #4961
base: main
Are you sure you want to change the base?
feat(client_cli): Integrating CLI API to set and retrieve parameters. #4961
Conversation
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification, and it looks like your proposed title needs to be adjusted. Details:
|
Okay, so @nxsaken and others. This draft PR might have several errors and the code might not be the best, bear with me as I fix these things. |
impl RunArgs for Get { | ||
fn run(self, context: &mut dyn RunContext) -> Result<()> { | ||
let client = context.client_from_config(); | ||
let vec = match self { | ||
Self::All => client | ||
.request(client::parameter::all()) | ||
.wrap_err("Failed to get all the parameters."), | ||
Self::Inner(param) => client | ||
.build_query(client::parameter::all()) | ||
.with_filter(ParamCmd::Sumeragi) | ||
.execute() | ||
.wrap_err("Failed to get the parameter value"), | ||
}?; | ||
context.print_data(&vec.collect::<QueryResult<Vec<_>>>()?)?; | ||
Ok(()) | ||
} | ||
} |
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.
So the first thing is here, I tried to replicate this from another commit, but I'm stuck on how to get the specific parameters that are in ParamCmd
. I'd like some suggestion on that.
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.
client::parameter::all()
returns Parameters
, which has all the parameters as fields. No need to filter here. You need to map ParamCmd
to the correct field in Parameters
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.
You will also need to make a version of ParamCmd
and its nested types without the value
field for this.
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.
You will also need to make a version of
ParamCmd
and its nested types without thevalue
field for this.
@nxsaken I would need to duplicate it again? That seems weird. Maybe ParamCmd
could be refactored for the better?
impl RunArgs for Set { | ||
fn run(self, context: &mut dyn RunContext) -> Result<()> { | ||
let set_param_value = SetParameter::new(0); | ||
// Not sure what to do. | ||
Ok(()) | ||
} | ||
} |
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.
And similarly, how do we exactly take the parameters from the hierarchy we have and actually set them? I believe we need to use SetParameter
from data_model::parameter
, but don't know how to go further on it.
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.
SetParameter
is an Instruction
, which can be submitted to an Iroha Client
. You need to turn self
into a SetParameter
here, and then call submit
(defined in this file).
impl RunArgs for Get { | ||
fn run(self, context: &mut dyn RunContext) -> Result<()> { | ||
let client = context.client_from_config(); | ||
let vec = match self { | ||
Self::All => client | ||
.request(client::parameter::all()) | ||
.wrap_err("Failed to get all the parameters."), | ||
Self::Inner(param) => client | ||
.build_query(client::parameter::all()) | ||
.with_filter(ParamCmd::Sumeragi) | ||
.execute() | ||
.wrap_err("Failed to get the parameter value"), | ||
}?; | ||
context.print_data(&vec.collect::<QueryResult<Vec<_>>>()?)?; | ||
Ok(()) | ||
} | ||
} |
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.
client::parameter::all()
returns Parameters
, which has all the parameters as fields. No need to filter here. You need to map ParamCmd
to the correct field in Parameters
impl RunArgs for Set { | ||
fn run(self, context: &mut dyn RunContext) -> Result<()> { | ||
let set_param_value = SetParameter::new(0); | ||
// Not sure what to do. | ||
Ok(()) | ||
} | ||
} |
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.
SetParameter
is an Instruction
, which can be submitted to an Iroha Client
. You need to turn self
into a SetParameter
here, and then call submit
(defined in this file).
impl RunArgs for Get { | ||
fn run(self, context: &mut dyn RunContext) -> Result<()> { | ||
let client = context.client_from_config(); | ||
let vec = match self { | ||
Self::All => client | ||
.request(client::parameter::all()) | ||
.wrap_err("Failed to get all the parameters."), | ||
Self::Inner(param) => client | ||
.build_query(client::parameter::all()) | ||
.with_filter(ParamCmd::Sumeragi) | ||
.execute() | ||
.wrap_err("Failed to get the parameter value"), | ||
}?; | ||
context.print_data(&vec.collect::<QueryResult<Vec<_>>>()?)?; | ||
Ok(()) | ||
} | ||
} |
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.
You will also need to make a version of ParamCmd
and its nested types without the value
field for this.
8058cee
to
cd9778e
Compare
Signed-off-by: Divya Ranjan <divya@subvertising.org>
cd9778e
to
4b9c479
Compare
@nxsaken what's the state with this? |
@divyaranjan1905 hi, do you plan to finish this PR? |
I do, I've simply been on a hiatus due to some stuff. I plan to get back on this within a week or so. |
should I assume this abandoned? |
It isn't, I have been busy with guiding someone's PhD, I would eventually be pushing this for merge. |
Description
This PR would integrate the necessary patchwork needed to ensure that one could use the
client_cli
ofiroha
to perform operations to set new values for parameters and retrieve existing ones.Linked issue
Closes #4820
Benefits
This creates an easier way for the user to modify parameter values.
Checklist
CONTRIBUTING.md