Comments (3)
Possibly allowing an additional spec to be passed to brewtils.load_config
that would be merged with brewtil's spec?
from brewtils.
May be better to just allow plugin authors to pass in their own argparser. That way they aren't required to learn / use yapconf.
EDIT: So this isn't as straightforward as I hoped. Passing in a custom parser to load_config
is no problem, and that's good because it allows for successful parsing of 'extra' cli args (like any positional args). The issue is getting access to the results - load_config
turns the results of the cli parsing into a dictionary and passes that to yapconf as a source. But because the 'extra' arguments aren't in the brewtils spec yapconf just drops them on the floor.
# cli args are ["arg value", "--bg-host", "localhost"]
def main():
parser = ArgumentParser()
parser.add_argument('some_arg')
# yay, this works now (doesn't barf on the positional arg)
config = brewtils.load_config(cli_args=sys.argv[1:], arg_parser=parser)
# Let's assume the client needs the thing
# This breaks because config.some_arg doesn't exist and there's no way to get it
RemotePlugin(Client(config.some_arg),
name='complex', ...,
**brewtils.get_connection_info(cli_args=sys.argv[1:])
In order to make this work we'd need some way to return the results of the argparser in addition to the yapconf Box. If we go this route, I don't see any way to avoid having some sort of separate config object, and that may be more confusing than just asking people to write a spec.
Another option: we provide a way to get an argparser that's already loaded with the brewtils spec. That way they could parse cli args themselves and the --help
would look as expected.
# cli args are ["arg value", "--bg-host", "localhost"]
def main():
parser = brewtils.argument_parser()
parser.add_argument('some_arg')
parsed_args = parser.parse_args(cli_args)
# sweet, now I can get to some_arg...
RemotePlugin(Client(parsed_args.some_arg),
name='complex', ...,
# BUT you can't use the cli args here, we can't deal with the extras
**brewtils.get_connection_info(**vars(parsed_args)))
This is still not great - if you're actually using get_config
instead of get_connection_info
you'll have two different config objects and you'll just have to know which has which things.
I think just adding some spec is easier, as long as you're ok giving up positional args:
# cli args are ["--some-arg", "arg value", "--bg-host", "localhost"]
def main():
extra_spec = {
"some_arg": {
"type": "str",
}
}
config = brewtils.load_config(cli_args=sys.argv[1:], merge_specification=extra_spec)
RemotePlugin(Client(config.some_arg),
name='complex', ...,
**brewtils.get_connection_info(cli_args=sys.argv[1:]))
from brewtils.
@loganasherjones ping
from brewtils.
Related Issues (20)
- Always url encode when communicating with beer garden HOT 1
- Missing support for creating and destroying gardens in RestClient
- Create initial schemas for auth models
- Add EasyClient support for creating/destroying gardens
- Add garden name to models and schemas HOT 2
- Brewtils unit tests for file related functionality HOT 2
- Update RoleAssignmentSchema domain field to contain scope and identifiers HOT 1
- Add job execution functions to EasyClient
- Add status_updated_at field to Request model
- RoleAssignmentDomain needs support for the "Global" scope
- Update authentication handling to work with new beer-garden auth
- Add EasyClient functionality for 'reset_interval' argument with ad-hoc executions of jobs
- Add the ability to export garden connection configuration (Brewtils) HOT 3
- Support optional parameters of type "Bytes"
- Update easy_client handling of import_jobs api response
- Deprecate form parameter of the command decorator HOT 1
- RestClient requires username and password for certificate authentication
- PikaClient does not load client certificates
- Python 3.10 support
- Requirement for packaging<21 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brewtils.