#301 List of available config accessible for end-users#327
Conversation
| # Default config | ||
| _DEFCONFIG = 'ITER' | ||
|
|
||
| def _get_listconfig(dconfig=_DCONFIG, dconfig_table=_DCONFIG_TABLE, |
There was a problem hiding this comment.
core hidden method
It is the base that provides either a dict or a str (formatted message) containing the core info
There was a problem hiding this comment.
This is great. However, I would suggest adding a short docstring to the new method and its intended use.
In particular, this would allow to describe in words what _DCONFIG and _DCONFIG_TABLE is
(to me, it's not clear what the difference is).
| return msg | ||
|
|
||
|
|
||
| def get_available_config(dconfig=_DCONFIG, dconfig_table=_DCONFIG_TABLE, |
There was a problem hiding this comment.
Public method for end-users
There was a problem hiding this comment.
Same here, a docstring would be nice.
Also, since this is a new public method, it should be added to __all__ no? As far as I can tell this is not the case.
Otherwise the message is nicely written, especially the use of an URL is good I believe.
| + "\t - unique keys: {}\n".format(list(dconfig.keys())) | ||
| + "\t - shortcuts : {}\n\n".format(list(dconfig_table.keys())) | ||
| + " => you provided: case = {}\n".format(config)) | ||
| msg = ("\nThe provided config name is not valid.\n" |
There was a problem hiding this comment.
This error message re-uses the formatted message created by the hidden method
… tf.geom.utils.create_Config()
Codecov Report
@@ Coverage Diff @@
## devel #327 +/- ##
========================================
Coverage ? 40.04%
========================================
Files ? 79
Lines ? 24111
Branches ? 0
========================================
Hits ? 9656
Misses ? 14455
Partials ? 0
Continue to review full report at Codecov.
|
flothesof
left a comment
There was a problem hiding this comment.
Good work :)
I've spotted one major thing (all missing) and some minor stuff (docstrings).
| # Default config | ||
| _DEFCONFIG = 'ITER' | ||
|
|
||
| def _get_listconfig(dconfig=_DCONFIG, dconfig_table=_DCONFIG_TABLE, |
There was a problem hiding this comment.
This is great. However, I would suggest adding a short docstring to the new method and its intended use.
In particular, this would allow to describe in words what _DCONFIG and _DCONFIG_TABLE is
(to me, it's not clear what the difference is).
| return msg | ||
|
|
||
|
|
||
| def get_available_config(dconfig=_DCONFIG, dconfig_table=_DCONFIG_TABLE, |
There was a problem hiding this comment.
Same here, a docstring would be nice.
Also, since this is a new public method, it should be added to __all__ no? As far as I can tell this is not the case.
Otherwise the message is nicely written, especially the use of an URL is good I believe.
…cluded new method in tf.geom.utils.__all__
…ect/tofu into Issue301_GetListConfigs
flothesof
left a comment
There was a problem hiding this comment.
One more small issue.
Other than that docstrings look great and thanks for the renaming of vars, I think it improves readability.
|
|
||
| def get_available_config(dconfig=_DCONFIG, | ||
| dconfig_shortcuts=_DCONFIG_SHORTCUTS, | ||
| verb=True, returnas=False): |
There was a problem hiding this comment.
Why is returnas a bool here? Shouldn't it be str?
Below there's a check if returnas is str...
What do you think?
There was a problem hiding this comment.
Nope, in general in many tofu functions / methods, returnas can be:
- False => nothing is returned
- None / True => set to default return format
- a specific format (here str)
It is because in this function there is only one output possible format, but that may evolve in the future.
The use of True / None is to specify we want output but either the user doesn't know that he has choice between several formats (in that case it is usually set to the most intuitive) or to let the format be decided later by another function.
I agree in this case we just have a choice between False (default) and str, but this way we keep the general workflow / convention
There was a problem hiding this comment.
I did not implement True / None because I forgot though,
But in 99 % cases users will not ask for returning anything
…config() (default to str)
Motivations:
As pointed out by issue #301 , in the online tutorial for plotting the gallery of fusion machines, we ask the user to read a hidden variable
tf.geom.utils._DCONFIG_TABLE.This is not good practice, a public method should exist to list all available pre-implemenetd configurations.
Main changes:
Two new methods are created, a hidden and a public:
tf.geom.utils._get_listconfig(): a hidden method used to generate the dict of (unique keys, shortcuts) from hidden variables_DCONFIGand_DCONFIG_TABLEand return either a fully formatted str message or the dict itself. It is used to provide the core message of the public method, and also re-used to properly generate the error message whentf.geom.utils.create_Config()is not properly called by the user.tf.geom.utils.get_available_config(): a public method that prints a fully formatted explicit message containing all available keys to pre-implemented configExample:
Issues:
Fixes, in devel, issue #301