-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Ability to explicitly set which arguments will be exposed/visible in the web ui #1876
Labels
Comments
Yes this would be nice. Maybe have a go at implementing it yourself? |
(either of your suggested solutions are fine but the second one is nicest, but I’m not sure how to implement it) |
A bit hacky, but something like this, could work: import unittest
from typing import List
import configargparse
class LocustArgumentParser(configargparse.ArgumentParser):
actions_excluded_from_ui: List[configargparse.Action] = []
def add_argument(self, *args, **kwargs):
exclude_from_ui = kwargs.pop('exclude_from_ui') if 'exclude_from_ui' in kwargs else None
action = super().add_argument(*args, **kwargs)
if exclude_from_ui:
self.actions_excluded_from_ui.append(action)
return action
class LocustArgumentParserTests(unittest.TestCase):
def test_sanity(self):
parser = LocustArgumentParser()
parser.add_argument("--a1", type=str, env_var="MYAPP_A1", default="a1_value", help="a1 help")
parser.add_argument("--a2", type=str, env_var="MYAPP_A2", default="a2_value", help="a2 help")
parser.add_argument("--a3", type=str, env_var="MYAPP_A3", default="a3_value", help="a3 help")
parser.add_argument("--a4", type=str, env_var="MYAPP_A4", default="a4_value", help="a4 help",
exclude_from_ui=True)
parser.add_argument("--a5", type=str, env_var="MYAPP_A5", default="a5_value", help="a5 help",
exclude_from_ui=True)
parser.parse_args([])
self.assertTrue(len(parser.actions_excluded_from_ui) == 2)
self.assertEqual('a4', parser.actions_excluded_from_ui[0].dest)
self.assertEqual('a5', parser.actions_excluded_from_ui[1].dest) One drawback is that the Line 74 in 5fb27aa
|
Looks nice! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
All custom arguments are shown in the web UI
Describe the solution you'd like
Ability to explicitly set which arguments will be exposed/visible in the web ui.
Perhaps a new flag ?
Or a new param to
add_argument
:Describe alternatives you've considered
ATM I am removing the options from CLI and just reading them directly from env variables.
The text was updated successfully, but these errors were encountered: