File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ import os
2
+ from pathlib import Path
3
+ import ssl
4
+ import tempfile
5
+ import urllib .request
6
+
1
7
from pyarrow import flight
2
8
3
- client = flight .connect ('grpc+tls://flight.spiceai.io' )
4
9
10
+ # Check for gRPC certificates
11
+ if not (Path (Path .cwd ().absolute ().anchor ) / 'usr' / 'share' / 'grpc' / 'roots.pem' ).exists ():
12
+ env_name = 'GRPC_DEFAULT_SSL_ROOTS_FILE_PATH'
13
+ if env_name not in os .environ or not Path (os .environ [env_name ]).exists ():
14
+ tls_root_certs = Path (tempfile .gettempdir ()) / 'roots.pem'
15
+ if not Path (tls_root_certs ).exists ():
16
+ print ('Downloading gRPC certificates' )
17
+ ssl ._create_default_https_context = ssl ._create_unverified_context
18
+ urllib .request .urlretrieve ('https://pki.google.com/roots.pem' , str (tls_root_certs ))
19
+ os .environ [env_name ] = str (tls_root_certs )
20
+
21
+ client = flight .connect ('grpc+tls://flight.spiceai.io' )
5
22
headers = [client .authenticate_basic_token ('' , 'API_KEY' )]
6
23
options = flight .FlightCallOptions (headers = headers )
7
24
You can’t perform that action at this time.
0 commit comments