Skip to content
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

dependant list added. #319

Open
wants to merge 6 commits into
base: master
from
Open

dependant list added. #319

wants to merge 6 commits into from

Conversation

@jtprof
Copy link
Contributor

@jtprof jtprof commented Jun 30, 2020

The values in the list, which are available to a user choice, depends on chosen values of other parameters.
The relations should be set in configuration manually.
Parameter configuration window in admin has not been changed.

The feature useful to avoid user to set inadmissible values combination.

Example in parameterized.json:
'aduld dogs food' in "Dependant List" variable is unavailable while "Cats", "Rats" or "Squirrel" is chosen in "Simple List" variable.

… user choice, depends on choosen values of othe parameters. The relations shoud be set in configuration manually. Parameter configuration window in admin has not been changed.
@jtprof
Copy link
Contributor Author

@jtprof jtprof commented Jul 1, 2020

A far as i have seen CI test failed due to f-string syntax (PEP 498).
May be it's good idea to increase project's requirements to Python 3.6 ?

Copy link
Owner

@bugy bugy left a comment

There are a couple of minor comments (mostly styling or wording). Great job!

@@ -1,4 +1,6 @@
PARAM_TYPE_SERVER_FILE = 'server_file'
PARAM_TYPE_MULTISELECT = 'multiselect'
PARAM_TYPE_LIST = 'list'
PARAM_TYPE_DEPENDANT_LIST = 'dependant_list'

This comment has been minimized.

@bugy

bugy Jul 5, 2020
Owner

I think this is not exactly "param type" because the type is still "list" (according to the example, you added)

This comment has been minimized.

@jtprof

jtprof Jul 6, 2020
Author Contributor

Formally you are right. But

  1. Other types (such 'text', 'int', etc.) don't have its own constants, so the file needs to refactor
  2. I believe the issue should been separated to its own type, so, it's for future use

This comment has been minimized.

@bugy

bugy Jul 8, 2020
Owner

Can we call it "list subtype" or smth like this? :)
I raised this concern only because I was confused while reading the code

"name": "Dependant List",
"param": "--dependant_list",
"type": "list",
"description": "The avalible values depends on other variables",

This comment has been minimized.

@bugy

bugy Jul 5, 2020
Owner

Could you fix typos please? :) "Available" "depend"

for key in self._values_conditions[e]:
pvalue = parameter_values.get(key)
if not is_empty(pvalue):
if not(pvalue in self._values_conditions[e][key] ):

This comment has been minimized.

@bugy

bugy Jul 5, 2020
Owner

could you change it to not in, please?

self._availible_values = set()
deny_values = set()

for e in self._values_conditions:

This comment has been minimized.

@bugy

bugy Jul 5, 2020
Owner

Could you rename e to something like possible_value, otherwise it's pretty hard to read

@@ -52,6 +52,46 @@ def __init__(self, script) -> None:
def get_values(self, parameter_values):
return self._values

class DependantValuesProvider(ValuesProvider):

This comment has been minimized.

@bugy

bugy Jul 5, 2020
Owner

Would you mind adding a couple of tests for this class? Specifically for get_values method

@bugy
Copy link
Owner

@bugy bugy commented Jul 5, 2020

Hi @jtprof Thanks a lot for the PR! and really sorry for the late response, it was quite busy week for me.
I left a couple of small comments for the code.

Regarding python 3.6: I would love to use f-strings also, but I think there are still some people using python 3.5, so I would prefer to keep 3.5 compability for now, especially considering that 3.5 is still "active" python version https://devguide.python.org/#status-of-python-branches

@jtprof
Copy link
Contributor Author

@jtprof jtprof commented Jul 6, 2020

Hi @jtprof Thanks a lot for the PR! and really sorry for the late response, it was quite busy week for me.
No pressure.

I left a couple of small comments for the code.
I will fix.

Regarding python 3.6: I would love to use f-strings also, but I think there are still some people using python 3.5, so I would prefer to keep 3.5 compability for now, especially considering that 3.5 is still "active" python version https://devguide.python.org/#status-of-python-branches

2020-09-13 'End-of-life'. It's so close.

…'ipv6', 'int' types variable have been added as composed by script.
venv/

conf/rediska.conf

This comment has been minimized.

@bugy

bugy Jul 8, 2020
Owner

I think those are not needed

@@ -1,4 +1,6 @@
PARAM_TYPE_SERVER_FILE = 'server_file'
PARAM_TYPE_MULTISELECT = 'multiselect'
PARAM_TYPE_LIST = 'list'
PARAM_TYPE_DEPENDANT_LIST = 'dependant_list'

This comment has been minimized.

@bugy

bugy Jul 8, 2020
Owner

Can we call it "list subtype" or smth like this? :)
I raised this concern only because I was confused while reading the code

Daniel Rehelis and others added 3 commits Jul 13, 2020
Enable searchbox support on multiselect combobox
@bugy
Copy link
Owner

@bugy bugy commented Aug 15, 2020

HI @jtprof, sorry for being inactive here.

I started working on refactoring for this PR and thought how to make configuration of conditional values a bit simpler (at the moment it has multiple nested levels) and more generic (so that you can use patterns, comparison, etc.).
In the end, I came up with idea of writing simple conditions, like "Dog food": "${param1} in ['a', 'b', 'c'] and ${param2} > 0"
But then I realize, that this is already covered by a possibility to specify scripts. So instead of writing complicated config, you can always write a script and pass parameter values there. And then this script will be responsible for deciding which values are supported.
I understand, that for simple cases, which you try to cover here, a script might be overhead, but as for me, it still keeps config cleaner and reduces code complexity of script server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.