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

Aca-py startup arg updates #739

Merged
merged 12 commits into from
Oct 7, 2020

Conversation

ianco
Copy link
Contributor

@ianco ianco commented Oct 2, 2020

Make "--endpoint" required. Make genesis required (url, file or txns) unless "--no-ledger" is specified. Make some "indy" wallet parameters required (name, key, etc) if indy wallet type is specified.

Added "--arg-file " to allow params to be included in a file. (File is just a list of args, not structured with yml etc) Had to change some related logic - couldn't flag args as "required" so moved the check to the "get_settings()" method and threw "ArgsParseError"; display usage on any ArgsParseError. (Had to fix a couple of unit tests that expected the "old" behaviour.

Related to issue #521

Copy link
Contributor

@swcurran swcurran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@codecov-commenter
Copy link

Codecov Report

Merging #739 into master will decrease coverage by 0.02%.
The diff coverage is 72.09%.

@@            Coverage Diff             @@
##           master     #739      +/-   ##
==========================================
- Coverage   99.01%   98.99%   -0.03%     
==========================================
  Files         256      256              
  Lines       13956    13975      +19     
==========================================
+ Hits        13819    13835      +16     
- Misses        137      140       +3     

@swcurran
Copy link
Contributor

swcurran commented Oct 2, 2020

Hmmm... -0.03% takes us below 99%. That's sad...

@ianco ianco marked this pull request as ready for review October 2, 2020 22:35
@ianco
Copy link
Contributor Author

ianco commented Oct 2, 2020

Note that configargparse is pointing to my fork (in requirements.txt) pending them accepting my PR

@ianco
Copy link
Contributor Author

ianco commented Oct 5, 2020

Some discussion around environment variables - the "ConfigArgParse" library adds support for env vars, but they must be configured per parameter, like for example:

    parser.add_argument("--wallet-storage-config", env_var="ACAPY_WALLET_STORAGE_CONFIG", help='....')

If the environment variable is present the value gets used, regardless of whether there is a config file or not.

However you cannot substitute env vars in the config file, like the following:

    input-transport = [["http", "${HOST}", "${PORT}"]]

The list of available environment variables (from the parser.add_argument() functions) is included in the usage() ("aca-py -h"), like:

--wallet-rekey
Specifies .... [env var: ACAPY_WALLET_REKEY]

Signed-off-by: Ian Costanzo <[email protected]>
@swcurran
Copy link
Contributor

swcurran commented Oct 5, 2020

Some discussion around environment variables - the "ConfigArgParse" library adds support for env vars, but they must be configured per parameter, like for example:

    parser.add_argument("--wallet-storage-config", env_var="ACAPY_WALLET_STORAGE_CONFIG", help='....')

If the environment variable is present the value gets used, regardless of whether there is a config file or not.

However you cannot substitute env vars in the config file, like the following:

    input-transport = [["http", "${HOST}", "${PORT}"]]

The list of available environment variables (from the parser.add_argument() functions) is included in the usage() ("aca-py -h"), like:

--wallet-rekey
Specifies .... [env var: ACAPY_WALLET_REKEY]

IMHO - this is even better. We get DRY documentation, we tightly tie the environment variables to the arguments. It does change how we have to environment variables, but the change looks like it moves us in the right direction. Ideal to use this always.

Next challenge -- being able to use argparse as defined here in bash scripts :-) -- that would be awesome...

@ianco
Copy link
Contributor Author

ianco commented Oct 5, 2020

It's not perfect - it would be nice to have the param substitution within the config file as well.

For example multi-value parameters (like "input-transport", which is also a multi-instance parameter = multi instances of multi values) would be confusing to jam into a single environment variable.

@swcurran
Copy link
Contributor

swcurran commented Oct 5, 2020

Except there is a very clear rule on how to do it, with usage information that makes it precise. What we are doing now is mixing and matching approaches that vary from variable to variable. Neither is perfect, but I would lean to consistency.

But my vote doesn't count much (and rightly so :-) ) in these decisions.

@ianco
Copy link
Contributor Author

ianco commented Oct 6, 2020

Env vars configured for:

--admin-api-key: ACAPY_ADMIN_API_KEY
--webhook-url: ACAPY_WEBHOOK_URL
--seed: ACAPY_WALLET_SEED
--wallet-key: ACAPY_WALLET_KEY
--wallet-rekey: ACAPY_WALLET_REKEY
--wallet-storage-config: ACAPY_WALLET_STORAGE_CONFIG
--wallet-storage-creds: ACAPY_WALLET_STORAGE_CREDS

@esune
Copy link
Member

esune commented Oct 6, 2020

--admin-api-key: ACAPY_ADMIN_API_KEY
--webhook-url: ACAPY_WEBHOOK_URL
--seed: ACAPY_WALLET_SEED
--wallet-key: ACAPY_WALLET_KEY
--wallet-rekey: ACAPY_WALLET_REKEY
--wallet-storage-config: ACAPY_WALLET_STORAGE_CONFIG
--wallet-storage-creds: ACAPY_WALLET_STORAGE_CREDS

Additional settings that we will likely need an environment variables for:
--label
--tails-server-base-url
--wallet-type
--wallet-storage-type
--wallet-storage-creds
--wallet-storage-config
--endpoint

If it was possible to use an environment variable to drive whether the agent starts in insecure mode or uses an api-key it would be good, but maybe out of scope now (this could also be tied to whether the admin interface is activated or not - I can't think of a use for an agent that has no admin interface).

In general I would think having environment variables for all - or at least as many as possible - of the settings would be a good idea, both for consistency and especially when working with cloud deployments of any kind, where they are the easiest way to deal with configurations. At the same time, I realize that some of the environment variables (see the api-key/admin interface example above) would potentially force us to build additional logic to check whether other environment variables are set based on their value. This is a bigger job than we maybe willing to do now, but will definitely make the agents more user-friendly and resilient.

@ianco
Copy link
Contributor Author

ianco commented Oct 6, 2020

--admin-api-key: ACAPY_ADMIN_API_KEY
--webhook-url: ACAPY_WEBHOOK_URL
--seed: ACAPY_WALLET_SEED
--wallet-key: ACAPY_WALLET_KEY
--wallet-rekey: ACAPY_WALLET_REKEY
--wallet-storage-config: ACAPY_WALLET_STORAGE_CONFIG
--wallet-storage-creds: ACAPY_WALLET_STORAGE_CREDS

Additional settings that we will likely need an environment variables for:
--label
--tails-server-base-url
--wallet-type
--wallet-storage-type
--wallet-storage-creds
--wallet-storage-config
--endpoint

If it was possible to use an environment variable to drive whether the agent starts in insecure mode or uses an api-key it would be good, but maybe out of scope now (this could also be tied to whether the admin interface is activated or not - I can't think of a use for an agent that has no admin interface).

In general I would think having environment variables for all - or at least as many as possible - of the settings would be a good idea, both for consistency and especially when working with cloud deployments of any kind, where they are the easiest way to deal with configurations. At the same time, I realize that some of the environment variables (see the api-key/admin interface example above) would potentially force us to build additional logic to check whether other environment variables are set based on their value. This is a bigger job than we maybe willing to do now, but will definitely make the agents more user-friendly and resilient.

Added

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@015928f). Click here to learn what that means.
The diff coverage is 72.09%.

@@            Coverage Diff            @@
##             master     #739   +/-   ##
=========================================
  Coverage          ?   98.99%           
=========================================
  Files             ?      256           
  Lines             ?    13975           
  Branches          ?        0           
=========================================
  Hits              ?    13835           
  Misses            ?      140           
  Partials          ?        0           

Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks @ianco

py_multicodec==0.2.1
git+https://github.com/ianco/ConfigArgParse.git#egg=ConfigArgParse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log an issue to remember updating this dependency, when you PR is merged?

Copy link
Contributor

@WadeBarnes WadeBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@andrewwhitehead andrewwhitehead merged commit 1f9a3bc into openwallet-foundation:master Oct 7, 2020
@ianco ianco deleted the args_updates branch December 2, 2020 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants