external-systems 0.3.0__py3-none-any.whl → 0.101.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of external-systems might be problematic. Click here for more details.

@@ -16,4 +16,4 @@
16
16
  # The version is set during the publishing step (since we can't know the version in advance)
17
17
  # using the autorelease bot
18
18
 
19
- __version__ = "0.3.0"
19
+ __version__ = "0.101.0"
@@ -20,6 +20,22 @@ from requests.adapters import HTTPAdapter
20
20
  from urllib3.util.retry import Retry
21
21
 
22
22
 
23
+ class CustomCaBundleSession(Session):
24
+ """
25
+ A wrapper for requests.Session to override 'verify' property, ignoring REQUESTS_CA_BUNDLE environment variable.
26
+
27
+ This is a workaround for https://github.com/psf/requests/issues/3829 (will be fixed in requests 3.0.0)
28
+ """
29
+
30
+ def merge_environment_settings(self, url, proxies, stream, verify, *args, **kwargs): # type: ignore[no-untyped-def]
31
+ if isinstance(self.verify, str):
32
+ verify = self.verify
33
+
34
+ return super(CustomCaBundleSession, self).merge_environment_settings(
35
+ url, proxies, stream, verify, *args, **kwargs
36
+ )
37
+
38
+
23
39
  class RetryingTimeoutHttpAdapter(HTTPAdapter):
24
40
  def __init__(
25
41
  self,
@@ -83,7 +99,7 @@ def create_proxy_session(proxy_url: str, proxy_token: str) -> Session:
83
99
  """
84
100
 
85
101
  adapter = ProxyAdapter(proxy_auth={proxy_url: f"Bearer {proxy_token}"})
86
- session = Session()
102
+ session = CustomCaBundleSession()
87
103
  session.mount("http://", adapter)
88
104
  session.mount("https://", adapter)
89
105
  session.proxies = {"all": proxy_url}
@@ -110,7 +126,7 @@ def create_session(
110
126
  timeout (Optional[Union[float, tuple[float, float], tuple[float, None]]]): Timeout settings for the session.
111
127
  """
112
128
 
113
- session = Session()
129
+ session = CustomCaBundleSession()
114
130
 
115
131
  if cert:
116
132
  session.cert = cert
@@ -104,7 +104,7 @@ class Source:
104
104
  new_ca_contents.append(required_ca)
105
105
 
106
106
  with NamedTemporaryFile(delete=False, mode="w") as ca_bundle_file:
107
- ca_bundle_file.write(os.linesep.join(new_ca_contents) + os.linesep)
107
+ ca_bundle_file.write("".join(new_ca_contents) + os.linesep)
108
108
  return ca_bundle_file.name
109
109
 
110
110
  @cached_property
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.3
2
+ Name: external-systems
3
+ Version: 0.101.0
4
+ Summary: A Python library for interacting with Foundry Sources
5
+ License: Apache-2.0
6
+ Keywords: Palantir,Foundry,Sources,Compute Modules,Python Functions,Transforms
7
+ Author: Palantir Technologies, Inc.
8
+ Requires-Python: >=3.9,<4.0
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.9
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Dist: frozendict (>=2.4.6,<3.0.0)
17
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
18
+ Project-URL: Repository, https://github.com/palantir/external-systems
19
+ Description-Content-Type: text/markdown
20
+
21
+ # External Systems
22
+
23
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/external-systems)
24
+ [![PyPI](https://img.shields.io/pypi/v/external-systems)](https://pypi.org/project/external-systems/)
25
+ [![License](https://img.shields.io/badge/License-Apache%202.0-lightgrey.svg)](https://opensource.org/licenses/Apache-2.0)
26
+ <a href="https://autorelease.general.dmz.palantir.tech/palantir/external-systems"><img src="https://img.shields.io/badge/Perform%20an-Autorelease-success.svg" alt="Autorelease"></a>
27
+
28
+ > [!WARNING]
29
+ > This SDK is incubating and subject to change.
30
+
31
+ ## About Foundry Sources
32
+
33
+ The External Systems library is Python SDK built as an interface to reference [Foundry Sources](https://www.palantir.com/docs/foundry/data-connection/set-up-source) from code.
34
+
35
+ ## Installation
36
+
37
+ You can install the Python package using `pip`:
38
+
39
+ ```sh
40
+ pip install external-systems
41
+ ```
42
+
43
+ ## Basic Source Usage
44
+
45
+ ### HTTP Client
46
+
47
+ For REST based sources, a preconfigured HTTP client is provided built on top of the Python requests library. For on-prem systems using [Agent Proxy](https://www.palantir.com/docs/foundry/data-connection/agent-proxy-runtime) the client will be pre-configured with the corresponding proxy
48
+
49
+ ```python
50
+ from external_systems.sources import Source, HttpsConnection
51
+ from requests import Session
52
+
53
+ my_source: Source = ...
54
+
55
+ https_connection: HttpsConnection = my_source.get_https_connection()
56
+
57
+ source_url: str = https_connection.url
58
+ http_client: Session = https_connection.get_client()
59
+
60
+ response = http_client.get(source_url + "/api/v1/example/", timeout=10)
61
+ ```
62
+
63
+ ### Secrets
64
+
65
+ Source secrets can be referenced using `get_secret("<secret_name>")` on the source.
66
+
67
+ ```python
68
+ from external_systems.sources import Source
69
+
70
+ my_source: Source = ...
71
+
72
+ some_secret: str = my_source.get_secret("SECRET_NAME")
73
+ ```
74
+
75
+ For sources using session credentials we support credentials generation and refresh management. Currently on an S3 source you can access session credentials using `get_aws_credentials()`. This method will throw if the source is not pre-configured with `AwsCredentials`
76
+
77
+ _Session credentials may not be available in all Foundry runtime environments_
78
+
79
+ ```python
80
+ from external_systems.sources import Source, Refreshable, AwsCredentials
81
+
82
+ s3_source: Source = ...
83
+
84
+ refreshable_credentials: Refreshable[AwsCredentials] = s3_source.get_aws_credentials()
85
+
86
+ session_credentials: AwsCredentials = refreshable_credentials.get()
87
+ ```
88
+
89
+ ## On-prem Connectivity with [Foundry Agent Proxy](https://www.palantir.com/docs/foundry/data-connection/agent-proxy-runtime)
90
+
91
+ ### Socket
92
+
93
+ For non-HTTP connections to external systems that require connections through Foundry's agent proxy, a pre-configured socket is provided.
94
+
95
+ #### On-Prem SFTP Server Example
96
+
97
+ For this example we'll be using the [fabric](https://docs.fabfile.org/en/latest/) library
98
+
99
+ ```python
100
+ import fabric
101
+
102
+ from external_systems.sources import Source
103
+ from socket import socket
104
+
105
+ SFTP_HOST = <sftp_host>
106
+ SFTP_PORT = <sftp_port>
107
+
108
+ on_prem_proxied_source: Source = ...
109
+
110
+ username: str = on_prem_sftp_server.get_secret("username")
111
+ password: str = on_prem_sftp_server.get_secret("password")
112
+
113
+ proxy_socket: socket = source.create_socket(SFTP_HOST, SFTP_PORT)
114
+
115
+ with fabric.Connection(
116
+ SFTP_HOST,
117
+ user=username,
118
+ port=SFTP_PORT,
119
+ connect_kwargs={
120
+ "password": password,
121
+ "sock": proxy_socket,
122
+ },
123
+ ) as conn:
124
+ sftp = conn.sftp()
125
+ file_list = sftp.listdir(".")
126
+ ```
127
+
128
+ ### Authenticated Proxy URI
129
+
130
+ For more granular use cases a pre-authenticated proxy URI is provided to allow connections to on-prem external systems.
131
+
132
+ #### Example
133
+
134
+ We'll be using the [httpx](https://www.python-httpx.org/) library.
135
+
136
+ ```python
137
+ import httpx
138
+
139
+ from external_systems.sources import Source
140
+
141
+ on_prem_system: Source = ...
142
+
143
+ authenticated_proxy_uri: str = on_prem_system.get_https_proxy_uri()
144
+
145
+ with httpx.Client(proxy=authenticated_proxy_uri) as client:
146
+ ...
147
+ ```
148
+
@@ -1,15 +1,15 @@
1
1
  external_systems/__init__.py,sha256=xXDUDD6_qRO-nHuXZx-fXp0R0vc3N_OOsB1F5mF_kpU,651
2
- external_systems/_version.py,sha256=503mW5iHo4pPU1LsKVjxJbPWpROSdU5pbVecB40NRUo,747
2
+ external_systems/_version.py,sha256=9hkOxbttQyoLltCQjmnoaDeX4KAllY-mbHklbzg-X4Q,749
3
3
  external_systems/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  external_systems/sources/__init__.py,sha256=aqXbMIy_pnyIC1uPRzQfApLCbhYB4N8iRFnpOX4RdAk,1156
5
5
  external_systems/sources/_api.py,sha256=NV7oNIgzSWz4ROFW8uPpUJjDN5vfFzdTs3yKC37S39k,3262
6
6
  external_systems/sources/_connections.py,sha256=h82npEks29NALAAfMHrXcSnB7TY_OLeXgL3QN9Cssus,2509
7
- external_systems/sources/_proxies.py,sha256=igWRL-kpQ_IlZyJwI_s66rDe0oQ68ltGeFNydgoiR4w,5071
7
+ external_systems/sources/_proxies.py,sha256=8Rq197KkGXVkwlK8lJNxrs3b1xul09XGh9E4r9nedgA,5722
8
8
  external_systems/sources/_refreshable.py,sha256=0pa5XW0_2gTMW-ZymKhlhh3Kka_bWTWffThKvrTTifc,4421
9
9
  external_systems/sources/_sockets.py,sha256=XH51adVnloqg8XYVHPxl6K8R_q2BCh6WZ77cq1L8nRg,4473
10
- external_systems/sources/_sources.py,sha256=-DP1QzuCtXOnsijwTNxI9x2vyEmxgyRB47ZTVQshfXA,10829
10
+ external_systems/sources/_sources.py,sha256=Nqu61CGKyUlErtImCz6tmq8y9RYeEJJ6AGHXA4o5HwA,10821
11
11
  external_systems/sources/_utils.py,sha256=EmUKKiKRDOZ2cZs7FZ4qCSan_lq1K_tquh3kxleB-jA,1004
12
- external_systems-0.3.0.dist-info/LICENSE.txt,sha256=NAk6Uc9K_N_J5V75k9qECpzUnO-ujT-mKK_jk_mboUE,569
13
- external_systems-0.3.0.dist-info/METADATA,sha256=YQy9SBjwSKsHIkjiA9snCZGeQbLryY9GRtmTXpJ2BYw,2694
14
- external_systems-0.3.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
15
- external_systems-0.3.0.dist-info/RECORD,,
12
+ external_systems-0.101.0.dist-info/LICENSE.txt,sha256=NAk6Uc9K_N_J5V75k9qECpzUnO-ujT-mKK_jk_mboUE,569
13
+ external_systems-0.101.0.dist-info/METADATA,sha256=1-jviWJdLiO9z7kXY8IsTVvH-PKUfC0d8B9VhY9BAeU,4765
14
+ external_systems-0.101.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
15
+ external_systems-0.101.0.dist-info/RECORD,,
@@ -1,75 +0,0 @@
1
- Metadata-Version: 2.3
2
- Name: external-systems
3
- Version: 0.3.0
4
- Summary: A Python library for interacting with Foundry Sources
5
- License: Apache-2.0
6
- Keywords: Palantir,Foundry,Sources,Compute Modules,Python Functions,Transforms
7
- Author: Palantir Technologies, Inc.
8
- Requires-Python: >=3.9,<4.0
9
- Classifier: License :: OSI Approved :: Apache Software License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.9
12
- Classifier: Programming Language :: Python :: 3.10
13
- Classifier: Programming Language :: Python :: 3.11
14
- Classifier: Programming Language :: Python :: 3.12
15
- Classifier: Programming Language :: Python :: 3.13
16
- Requires-Dist: frozendict (>=2.4.6,<3.0.0)
17
- Requires-Dist: requests (>=2.32.3,<3.0.0)
18
- Project-URL: Repository, https://github.com/palantir/external-systems
19
- Description-Content-Type: text/markdown
20
-
21
- # External Systems
22
- ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/external-systems)
23
- [![PyPI](https://img.shields.io/pypi/v/external-systems)](https://pypi.org/project/external-systems/)
24
- [![License](https://img.shields.io/badge/License-Apache%202.0-lightgrey.svg)](https://opensource.org/licenses/Apache-2.0)
25
- <a href="https://autorelease.general.dmz.palantir.tech/palantir/external-systems"><img src="https://img.shields.io/badge/Perform%20an-Autorelease-success.svg" alt="Autorelease"></a>
26
-
27
- > [!WARNING]
28
- > This SDK is incubating and subject to change.
29
-
30
-
31
- ## About Foundry Sources
32
-
33
- The External Systems library is Python SDK built as an interface to reference [Foundry Sources](https://www.palantir.com/docs/foundry/data-connection/set-up-source) from code.
34
-
35
- <a id="installation"></a>
36
- ## Installation
37
- You can install the Python package using `pip`:
38
-
39
- ```sh
40
- pip install external-systems
41
- ```
42
-
43
- <a id="basic-usage"></a>
44
- ## Basic Source Usage
45
-
46
- ### Credentials
47
-
48
- Long lived credentials can be referenced using `get_secret()` on the source.
49
-
50
- ```python
51
- my_source: Source = ...
52
-
53
- some_secret = my_source.get_secret("SECRET_NAME")
54
- ```
55
-
56
- For sources using session credentials we support credentials generation and refresh management. Currently on an S3 source you can access session credentials using `get_aws_credentials()`.
57
-
58
- ```python
59
- s3_source: Source = ...
60
-
61
- refreshable_credentials: Refreshable[AwsCredentials] = s3_source.get_aws_credentials()
62
-
63
- session_credentials: AwsCredentials = refreshable_credentials.get()
64
- ```
65
-
66
- ### HTTP Client
67
- For REST based sources, a preconfigured HTTP client is provided built on top of the Python requests library.
68
-
69
- ```python
70
- source_url = my_source.get_https_connection().url
71
- http_client = my_source.get_https_connection().get_client()
72
-
73
- response = http_client.get(source_url + "/api/v1/example/", timeout=10)
74
- ```
75
-