foundry-dev-tools-transforms 2.1.17__tar.gz → 2.1.18__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foundry-dev-tools-transforms
3
- Version: 2.1.17
3
+ Version: 2.1.18
4
4
  Summary: Seamlessly run your Palantir Foundry Repository transforms code on your local machine.
5
5
  Author-Email: Nicolas Renkamp <nicolas.renkamp@merckgroup.com>, Jonas Wunderlich <jonas.wunderlich@merckgroup.com>
6
6
  License: Apache-2.0
@@ -34,7 +34,7 @@ dependencies = [
34
34
  "fs",
35
35
  ]
36
36
  dynamic = []
37
- version = "2.1.17"
37
+ version = "2.1.18"
38
38
 
39
39
  [project.license]
40
40
  text = "Apache-2.0"
@@ -0,0 +1 @@
1
+ __version__ = '2.1.18'
@@ -113,7 +113,7 @@ class Transform:
113
113
  """
114
114
  kwargs = {name: i.init_input(context).dataframe() for name, i in self.inputs.items()}
115
115
  if self._use_context:
116
- kwargs["ctx"] = TransformContext()
116
+ kwargs["ctx"] = TransformContext(context)
117
117
 
118
118
  output_df = self(**kwargs)
119
119
 
@@ -136,7 +136,7 @@ class Transform:
136
136
  """
137
137
  kwargs = {name: i.init_input(context).dataframe().toPandas() for name, i in self.inputs.items()}
138
138
  if self._use_context:
139
- kwargs["ctx"] = TransformContext()
139
+ kwargs["ctx"] = TransformContext(context)
140
140
 
141
141
  output_df = self(**kwargs)
142
142
  from foundry_dev_tools._optional.pandas import pd
@@ -159,7 +159,7 @@ class Transform:
159
159
  kwargs = {**inputs, **outputs}
160
160
 
161
161
  if self._use_context:
162
- kwargs["ctx"] = TransformContext()
162
+ kwargs["ctx"] = TransformContext(context)
163
163
 
164
164
  self(**kwargs)
165
165
 
@@ -169,10 +169,6 @@ class Transform:
169
169
  self,
170
170
  context: FoundryContext,
171
171
  ):
172
- if self._use_context:
173
- msg = "Lightweight transforms do not support the context argument."
174
- raise ValueError(msg)
175
-
176
172
  inputs = {argument_name: LightweightTransformInput(i, context) for argument_name, i in self.inputs.items()}
177
173
  outputs = {
178
174
  argument_name: LightweightTransformOutput(o, argument_name, context)
@@ -180,6 +176,9 @@ class Transform:
180
176
  }
181
177
  kwargs = {**inputs, **outputs}
182
178
 
179
+ if self._use_context:
180
+ kwargs["ctx"] = TransformContext(context)
181
+
183
182
  self(**kwargs)
184
183
 
185
184
  return {name: i.df for name, i in outputs.items()}
@@ -188,34 +187,30 @@ class Transform:
188
187
  self,
189
188
  context: FoundryContext,
190
189
  ) -> pd.core.frame.DataFrame:
191
- if self._use_context:
192
- msg = "Lightweight transforms do not support the context argument."
193
- raise ValueError(msg)
194
-
195
190
  inputs = {
196
191
  argument_name: LightweightTransformInput(i, context).pandas() for argument_name, i in self.inputs.items()
197
192
  }
193
+ if self._use_context:
194
+ inputs["ctx"] = TransformContext(context)
198
195
  return self(**inputs)
199
196
 
200
197
  def _compute_lightweight_polars(
201
198
  self,
202
199
  context: FoundryContext,
203
200
  ) -> pl.DataFrame:
204
- if self._use_context:
205
- msg = "Lightweight transforms do not support the context argument."
206
- raise ValueError(msg)
207
-
208
201
  inputs = {
209
202
  argument_name: LightweightTransformInput(i, context).polars() for argument_name, i in self.inputs.items()
210
203
  }
204
+ if self._use_context:
205
+ inputs["ctx"] = TransformContext(context)
211
206
  return self(**inputs)
212
207
 
213
208
 
214
209
  class TransformContext:
215
210
  """The TransformContext is passed to the transform function if ctx is the first argument."""
216
211
 
217
- def __init__(self):
218
- pass
212
+ def __init__(self, foundry_ctx: FoundryContext):
213
+ self._foundry_ctx = foundry_ctx
219
214
 
220
215
  @property
221
216
  def spark_session(self) -> pyspark.sql.SparkSession:
@@ -241,6 +236,10 @@ class TransformContext:
241
236
  warnings.warn("is_incremental functionality not implemented in Foundry DevTools")
242
237
  return False
243
238
 
239
+ @property
240
+ def auth_header(self) -> str:
241
+ return f"Bearer {self._foundry_ctx.token_provider.token}"
242
+
244
243
 
245
244
  class TransformInput:
246
245
  """TransformInput class, passed when using @transform decorator."""
@@ -1 +0,0 @@
1
- __version__ = '2.1.17'