|
59 | 59 | expected_existing_expectations_store_yaml |
60 | 60 | ) |
61 | 61 |
|
62 | | -# adding expectations store |
63 | | -configured_expectations_store_yaml = """ |
64 | | -# <snippet name="docs/docusaurus/docs/snippets/aws_redshift_deployment_patterns.py new_expectations_store"> |
65 | | -stores: |
66 | | - expectations_S3_store: |
67 | | - class_name: ExpectationsStore |
68 | | - store_backend: |
69 | | - class_name: TupleS3StoreBackend |
70 | | - bucket: '<YOUR S3 BUCKET NAME>' |
71 | | - prefix: '<YOUR S3 PREFIX NAME>' # Bucket and prefix in combination must be unique across all stores |
72 | | -
|
73 | | -expectations_store_name: expectations_S3_store |
74 | | -# </snippet> |
75 | | -""" |
76 | | - |
77 | | -# replace example code with integration test configuration |
78 | | -configured_expectations_store = yaml.load(configured_expectations_store_yaml) |
79 | | -configured_expectations_store["stores"]["expectations_S3_store"]["store_backend"][ |
80 | | - "bucket" |
81 | | -] = "gx-golden-path-tests" |
82 | | -configured_expectations_store["stores"]["expectations_S3_store"]["store_backend"][ |
83 | | - "prefix" |
84 | | -] = "metadata/expectations" |
85 | | - |
86 | | -# add and set the new expectation store |
87 | | -context.add_store( |
88 | | - name=configured_expectations_store["expectations_store_name"], |
89 | | - config=configured_expectations_store["stores"]["expectations_S3_store"], |
90 | | -) |
91 | | -with open(great_expectations_yaml_file_path) as f: |
92 | | - great_expectations_yaml = yaml.load(f) |
93 | | -great_expectations_yaml["expectations_store_name"] = "expectations_S3_store" |
94 | | -great_expectations_yaml["stores"]["expectations_S3_store"]["store_backend"].pop( |
95 | | - "suppress_store_backend_id" |
96 | | -) |
97 | | -with open(great_expectations_yaml_file_path, "w") as f: |
98 | | - yaml.dump(great_expectations_yaml, f) |
99 | | - |
100 | | -# adding validation results store |
101 | | -great_expectations_yaml_file_path = pathlib.Path( |
102 | | - context.root_directory, FileDataContext.GX_YML |
103 | | -) |
104 | | -with open(great_expectations_yaml_file_path) as f: |
105 | | - great_expectations_yaml = yaml.load(f) |
106 | | - |
107 | | -stores = great_expectations_yaml["stores"] |
108 | | -# popping the rest out so that we can do the comparison. They aren't going anywhere dont worry |
109 | | -pop_stores = [ |
110 | | - "checkpoint_store", |
111 | | - "expectations_store", |
112 | | - "expectations_S3_store", |
113 | | - "validation_definition_store", |
114 | | -] |
115 | | -for store in pop_stores: |
116 | | - stores.pop(store) |
117 | | - |
118 | | -actual_existing_validation_results_store = {} |
119 | | -actual_existing_validation_results_store["stores"] = stores |
120 | | -actual_existing_validation_results_store["validation_results_store_name"] = ( |
121 | | - great_expectations_yaml["validation_results_store_name"] |
122 | | -) |
123 | | - |
124 | | -expected_existing_validation_results_store_yaml = """ |
125 | | -# <snippet name="docs/docusaurus/docs/snippets/aws_redshift_deployment_patterns.py existing_validation_results_store"> |
126 | | -stores: |
127 | | - validation_results_store: |
128 | | - class_name: ValidationResultsStore |
129 | | - store_backend: |
130 | | - class_name: TupleFilesystemStoreBackend |
131 | | - base_directory: uncommitted/validations/ |
132 | | -
|
133 | | -validation_results_store_name: validation_results_store |
134 | | -# </snippet> |
135 | | -""" |
136 | | - |
137 | | -assert actual_existing_validation_results_store == yaml.load( |
138 | | - expected_existing_validation_results_store_yaml |
139 | | -) |
140 | | - |
141 | | -# adding validations store |
142 | | -configured_validation_results_store_yaml = """ |
143 | | -# <snippet name="docs/docusaurus/docs/snippets/aws_redshift_deployment_patterns.py new_validation_results_store"> |
144 | | -stores: |
145 | | - validation_results_S3_store: |
146 | | - class_name: ValidationResultsStore |
147 | | - store_backend: |
148 | | - class_name: TupleS3StoreBackend |
149 | | - bucket: '<YOUR S3 BUCKET NAME>' |
150 | | - prefix: '<YOUR S3 PREFIX NAME>' # Bucket and prefix in combination must be unique across all stores |
151 | | -# </snippet> |
152 | | -
|
153 | | -# <snippet name="docs/docusaurus/docs/snippets/aws_redshift_deployment_patterns.py set_new_validation_results_store"> |
154 | | -validation_results_store_name: validation_results_S3_store |
155 | | -# </snippet> |
156 | | -""" |
157 | | - |
158 | | -# replace example code with integration test configuration |
159 | | -configured_validation_results_store = yaml.load( |
160 | | - configured_validation_results_store_yaml |
161 | | -) |
162 | | -configured_validation_results_store["stores"]["validation_results_S3_store"][ |
163 | | - "store_backend" |
164 | | -]["bucket"] = "gx-golden-path-tests" |
165 | | -configured_validation_results_store["stores"]["validation_results_S3_store"][ |
166 | | - "store_backend" |
167 | | -]["prefix"] = "metadata/validations" |
168 | | - |
169 | | -# add and set the new validation store |
170 | | -context.add_store( |
171 | | - name=configured_validation_results_store["validation_results_store_name"], |
172 | | - config=configured_validation_results_store["stores"]["validation_results_S3_store"], |
173 | | -) |
174 | | -with open(great_expectations_yaml_file_path) as f: |
175 | | - great_expectations_yaml = yaml.load(f) |
176 | | -great_expectations_yaml["validation_results_store_name"] = "validation_results_S3_store" |
177 | | -great_expectations_yaml["stores"]["validation_results_S3_store"]["store_backend"].pop( |
178 | | - "suppress_store_backend_id" |
179 | | -) |
180 | | -with open(great_expectations_yaml_file_path, "w") as f: |
181 | | - yaml.dump(great_expectations_yaml, f) |
182 | | - |
183 | | -# adding data docs store |
184 | | -data_docs_site_yaml = """ |
185 | | -# <snippet name="docs/docusaurus/docs/snippets/aws_redshift_deployment_patterns.py add_data_docs_store"> |
186 | | -data_docs_sites: |
187 | | - local_site: |
188 | | - class_name: SiteBuilder |
189 | | - show_how_to_buttons: true |
190 | | - store_backend: |
191 | | - class_name: TupleFilesystemStoreBackend |
192 | | - base_directory: uncommitted/data_docs/local_site/ |
193 | | - site_index_builder: |
194 | | - class_name: DefaultSiteIndexBuilder |
195 | | - S3_site: # this is a user-selected name - you may select your own |
196 | | - class_name: SiteBuilder |
197 | | - store_backend: |
198 | | - class_name: TupleS3StoreBackend |
199 | | - bucket: <YOUR S3 BUCKET NAME> |
200 | | - site_index_builder: |
201 | | - class_name: DefaultSiteIndexBuilder |
202 | | -# </snippet> |
203 | | -""" |
204 | | - |
205 | | -data_docs_site_yaml = data_docs_site_yaml.replace( |
206 | | - "<YOUR S3 BUCKET NAME>", "gx-demo-data-docs" |
207 | | -) |
208 | | -great_expectations_yaml_file_path = pathlib.Path( |
209 | | - context.root_directory, FileDataContext.GX_YML |
210 | | -) |
211 | | -with open(great_expectations_yaml_file_path) as f: |
212 | | - great_expectations_yaml = yaml.load(f) |
213 | | -great_expectations_yaml["data_docs_sites"] = yaml.load(data_docs_site_yaml)[ |
214 | | - "data_docs_sites" |
215 | | -] |
216 | | -with open(great_expectations_yaml_file_path, "w") as f: |
217 | | - yaml.dump(great_expectations_yaml, f) |
218 | | - |
219 | | - |
220 | 62 | # <snippet name="docs/docusaurus/docs/snippets/aws_redshift_deployment_patterns.py vars"> |
221 | 63 | datasource_name = "my_redshift_datasource" |
222 | 64 | connection_string = "redshift+psycopg2://<USER_NAME>:<PASSWORD>@<HOST>:<PORT>/<DATABASE>?sslmode=<SSLMODE>" |
|
0 commit comments