Skip to content

Commit e445c67

Browse files
Add sample config
1 parent 80dffbb commit e445c67

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This package contains common Python utility classes and functions.
1414
* Making requests to the Oauth2 authenticated APIs such as NYPL Platform API and Sierra
1515

1616
## Functions
17-
* Reading a YAML config file and putting the contents in os.environ
17+
* Reading a YAML config file and putting the contents in os.environ -- see `config/sample.yaml` for an example of how the config file should be formatted
1818
* Creating a logger in the appropriate format
1919
* Obfuscating a value using bcrypt
2020
* Parsing/building Research Catalog identifiers
@@ -57,8 +57,8 @@ When a new client or helper file is created, a new optional dependency set shoul
5757

5858
The optional dependency sets also give the developer the option to manually list out the dependencies of the clients rather than relying upon what the package thinks is required, which can be beneficial in certain circumstances. For instance, AWS lambda functions come with `boto3` and `botocore` pre-installed, so it's not necessary to include these (rather hefty) dependencies in the lambda deployment package.
5959

60-
### Troubleshooting
61-
#### Using PostgreSQLClient in an AWS Lambda
60+
## Troubleshooting
61+
### Using PostgreSQLClient in an AWS Lambda
6262
Because `psycopg` requires a statically linked version of the `libpq` library, the `PostgreSQLClient` cannot be installed as-is in an AWS Lambda function. Instead, it must be packaged as follows:
6363
```bash
6464
pip install --target ./package nypl-py-utils[postgresql-client]==1.1.2
@@ -72,7 +72,7 @@ pip install \
7272
'psycopg[binary]'
7373
```
7474

75-
#### Using PostgreSQLClient locally
75+
### Using PostgreSQLClient locally
7676
If using the `PostgreSQLClient` produces the following error locally:
7777
```
7878
ImportError: no pq wrapper available.

config/sample.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
PLAINTEXT_VARIABLES:
3+
STRING_VAR: string-var
4+
INT_VAR: 1
5+
LIST_VAR:
6+
- string-var2
7+
- 2
8+
ENCRYPTED_VARIABLES:
9+
ENCRYPTED_STRING_VAR: AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGowaAYJKoZIhvcNAQcGoFswWQIBADBUBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDCvE8Pc8PiUEiCGpEAIBEIAnf8fz6YXH959A0ygrM4S95giFnwvp9dYFzp/2ViAIlD5GZ1S04vay
10+
ENCRYPTED_INT_VAR: AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAF8wXQYJKoZIhvcNAQcGoFAwTgIBADBJBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDFQdg7ua7D8XH7UZGgIBEIAcpkIN6+56sbR3Vbk12NX2QDY28dnL8IWgVdnBRA==
11+
ENCRYPTED_LIST_VAR:
12+
- AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDMTe0jJyHxGaiy0PHQIBEIAo4+qpfJp/gfZqhl1GtN/q9ebn2isiVOn5QLK/fcUtWeG182jiKPdOFA==
13+
- AQECAHh7ea2tyZ6phZgT4B9BDKwguhlFtRC6hgt+7HbmeFsrsgAAAF8wXQYJKoZIhvcNAQcGoFAwTgIBADBJBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDGsG/1m7nes884q8vQIBEIAc9eBDgUgVzVsK3lyebNmc09kGfP7Gzwm6ESJAiA==
14+
...

src/nypl_py_utils/functions/config_helper.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ def load_env_file(run_type, file_string):
1616
exported into os.environ as a json string and should be loaded as such.
1717
1818
It requires the YAML file to be split into a 'PLAINTEXT_VARIABLES' section
19-
and an 'ENCRYPTED_VARIABLES' section.
19+
and an 'ENCRYPTED_VARIABLES' section. See config/sample.yaml for an example
20+
config file.
2021
2122
Parameters
2223
----------
2324
run_type: str
24-
The name of the config file to use, e.g. 'devel'
25+
The name of the config file to use, e.g. 'sample'
2526
file_string: str
2627
The path to the config files with the filename as a variable to be
2728
interpolated, e.g. 'config/{}.yaml'

0 commit comments

Comments
 (0)