omnata-plugin-runtime 0.5.7a141__py3-none-any.whl → 0.5.7a145__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.
@@ -2255,6 +2255,117 @@ class SnowflakeUDTFResultColumn:
2255
2255
  data_type: str
2256
2256
  description: str
2257
2257
 
2258
+ @dataclass
2259
+ class PythonUDTFDefinition:
2260
+ """
2261
+ The information needed by the plugin uploader to put a Python UDTF definition into the setup script.
2262
+ Do not use this class directly in plugins, instead use the consumer_udtf decorator.
2263
+ """
2264
+ name: str
2265
+ description: str
2266
+ params: List[SnowflakeFunctionParameter]
2267
+ result_columns: List[SnowflakeUDTFResultColumn]
2268
+ handler: str
2269
+ packages: Optional[List[str]] = None
2270
+
2271
+ def __str__(self):
2272
+ param_str = ', '.join([str(param) for param in self.params])
2273
+ table_result_columns = ', '.join([f"{col.name} {col.data_type}" for col in self.result_columns])
2274
+ packages_str = ', '.join([f"'{p}'" for p in self.packages])
2275
+ return f"""CREATE OR REPLACE FUNCTION UDFS.{self.name}({param_str})
2276
+ RETURNS TABLE({table_result_columns})
2277
+ LANGUAGE PYTHON
2278
+ RUNTIME_VERSION=3.10
2279
+ COMMENT = $${self.description}$$
2280
+ PACKAGES = ({packages_str})
2281
+ IMPORTS = ('/app.zip')
2282
+ HANDLER='{self.handler}';
2283
+ """
2284
+
2285
+ @dataclass
2286
+ class JavaUDTFDefinition:
2287
+ """
2288
+ The information needed by the plugin uploader to put a Java UDTF definition into the setup script.
2289
+ These are created directly in python, since we don't want the omnata cli to need to do any Java reflection.
2290
+ Any .jar files placed in the udf_direct_imports directory will be uploaded to the stage and can be
2291
+ added to the imports parameter as (e.g.) '/my_jar.jar'.
2292
+ """
2293
+ name: str
2294
+ description: str
2295
+ params: List[SnowflakeFunctionParameter]
2296
+ result_columns: List[SnowflakeUDTFResultColumn]
2297
+ packages: List[str]
2298
+ imports: List[str]
2299
+ handler: str
2300
+
2301
+ def __str__(self):
2302
+ param_str = ', '.join([str(param) for param in self.params])
2303
+ table_result_columns = ', '.join([f"{col.name} {col.data_type}" for col in self.result_columns])
2304
+ packages_str = ', '.join([f"'{p}'" for p in self.packages])
2305
+ imports_str = ', '.join([f"'{i}'" for i in self.imports])
2306
+ return f"""CREATE OR REPLACE FUNCTION UDFS.{self.name}({param_str})
2307
+ RETURNS TABLE({table_result_columns})
2308
+ LANGUAGE PYTHON
2309
+ RUNTIME_VERSION=3.10
2310
+ COMMENT = $${self.description}$$
2311
+ PACKAGES = ({packages_str})
2312
+ IMPORTS = ({imports_str})
2313
+ HANDLER='{self.handler}';
2314
+ """
2315
+
2316
+ @dataclass
2317
+ class PythonUDFDefinition:
2318
+ """
2319
+ The information needed by the plugin uploader to put a Python UDF definition into the setup script.
2320
+ Do not use this class directly in plugins, instead use the consumer_udf decorator.
2321
+ """
2322
+ name: str
2323
+ description: str
2324
+ params: List[SnowflakeFunctionParameter]
2325
+ result_data_type: str
2326
+ handler: str
2327
+ packages: Optional[List[str]] = None
2328
+
2329
+ def __str__(self):
2330
+ param_str = ', '.join([str(param) for param in self.params])
2331
+ packages_str = ', '.join([f"'{p}'" for p in self.packages])
2332
+ return f"""CREATE OR REPLACE FUNCTION UDFS.{self.name}({param_str})
2333
+ RETURNS {self.result_data_type}
2334
+ LANGUAGE PYTHON
2335
+ RUNTIME_VERSION=3.10
2336
+ COMMENT = $${self.description}$$
2337
+ PACKAGES = ({packages_str})
2338
+ IMPORTS = ('/app.zip')
2339
+ HANDLER='{self.handler}';
2340
+ """
2341
+
2342
+ @dataclass
2343
+ class JavaUDFDefinition:
2344
+ """
2345
+ The information needed by the plugin uploader to put a java UDF definition into the setup script.
2346
+ """
2347
+ name: str
2348
+ description: str
2349
+ params: List[SnowflakeFunctionParameter]
2350
+ result_data_type: str
2351
+ packages: List[str]
2352
+ imports: List[str]
2353
+ handler: str
2354
+
2355
+ def __str__(self):
2356
+ param_str = ', '.join([str(param) for param in self.params])
2357
+ packages_str = ', '.join([f"'{p}'" for p in self.packages])
2358
+ imports_str = ', '.join([f"'{i}'" for i in self.imports])
2359
+ return f"""CREATE OR REPLACE FUNCTION UDFS.{self.name}({param_str})
2360
+ RETURNS {self.result_data_type}
2361
+ LANGUAGE PYTHON
2362
+ RUNTIME_VERSION=3.10
2363
+ COMMENT = $${self.description}$$
2364
+ PACKAGES = ({packages_str})
2365
+ IMPORTS = ({imports_str})
2366
+ HANDLER='{self.handler}';
2367
+ """
2368
+
2258
2369
  def consumer_udtf(
2259
2370
  name:str,
2260
2371
  description: str,
@@ -2318,7 +2429,7 @@ def consumer_udtf(
2318
2429
 
2319
2430
  return class_decorator
2320
2431
 
2321
- def find_consumer_udtf_classes(path:str = '.') -> List[type]:
2432
+ def find_consumer_udtf_classes(path:str = '.') -> List[PythonUDTFDefinition | JavaUDTFDefinition]:
2322
2433
  """
2323
2434
  Finds all classes in the specified directory which have the 'consumer_udtf' decorator applied
2324
2435
  """
@@ -2337,7 +2448,16 @@ def find_consumer_udtf_classes(path:str = '.') -> List[type]:
2337
2448
  for name, obj in inspect.getmembers(module, inspect.isclass):
2338
2449
  # Check if the class has the specified attribute
2339
2450
  if hasattr(obj, '_is_omnata_consumer_udtf'):
2451
+ matching_classes.append(PythonUDTFDefinition(
2452
+ name=obj._omnata_consumer_udtf_name,
2453
+ description=obj._omnata_consumer_udtf_description,
2454
+ params=obj._omnata_consumer_udtf_params,
2455
+ result_columns=obj._omnata_consumer_udtf_result_columns,
2456
+ handler=obj.__module__+'.'+obj.__name__
2457
+ ))
2458
+ elif isinstance(obj, JavaUDTFDefinition):
2340
2459
  matching_classes.append(obj)
2460
+
2341
2461
  return matching_classes
2342
2462
 
2343
2463
 
@@ -2394,7 +2514,7 @@ def consumer_udf(
2394
2514
 
2395
2515
  return decorator
2396
2516
 
2397
- def find_consumer_udf_functions(path:str = '.') -> List[function]:
2517
+ def find_consumer_udf_functions(path:str = '.') -> List[PythonUDFDefinition | JavaUDFDefinition]:
2398
2518
  """
2399
2519
  Finds all functions in the specified directory which have the 'consumer_udf' decorator applied
2400
2520
  """
@@ -2413,6 +2533,15 @@ def find_consumer_udf_functions(path:str = '.') -> List[function]:
2413
2533
  for name, obj in inspect.getmembers(module, inspect.isfunction):
2414
2534
  # Check if the class has the specified attribute
2415
2535
  if hasattr(obj, '_is_omnata_consumer_udf'):
2536
+ matching_classes.append(PythonUDFDefinition(
2537
+ name=obj._omnata_consumer_udf_name,
2538
+ description=obj._omnata_consumer_udf_description,
2539
+ params=obj._omnata_consumer_udf_params,
2540
+ result_data_type=obj._omnata_consumer_udf_result_data_type,
2541
+ packages=[],
2542
+ handler=obj.__module__+'.'+obj.__name__
2543
+ ))
2544
+ elif isinstance(obj, JavaUDFDefinition):
2416
2545
  matching_classes.append(obj)
2417
2546
 
2418
2547
  return matching_classes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.5.7a141
3
+ Version: 0.5.7a145
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -3,10 +3,10 @@ omnata_plugin_runtime/api.py,sha256=FxzTqri4no8ClkOm7vZADG8aD47jcGBCTTQDEORmOJM,
3
3
  omnata_plugin_runtime/configuration.py,sha256=TI6GaVFhewVawBCaYN34GujY57qEP6q2nik4YpSEk5s,38100
4
4
  omnata_plugin_runtime/forms.py,sha256=GzSPEwcijsoPCXEO1mHiE8ylvX_KSE5TkhwqkymA2Ss,19755
5
5
  omnata_plugin_runtime/logging.py,sha256=bn7eKoNWvtuyTk7RTwBS9UARMtqkiICtgMtzq3KA2V0,3272
6
- omnata_plugin_runtime/omnata_plugin.py,sha256=TRD_t9QBXSGNHqn3u2ZjRhnxz2_-VBHDZUCRO0BvcQo,120165
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=PVgyiqHCXXqsUIbLnOFe9H2FRZB7o_4FiI-9KHzRsfg,125045
7
7
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=PFSLsYEVnWHVvSoOYTtTK2JY6pp6_8_eYP53WqLRiPE,27975
8
8
  omnata_plugin_runtime/rate_limiting.py,sha256=DVQ_bc-mVLBkrU1PTns1MWXhHiLpSB5HkWCcdePtJ2A,25611
9
- omnata_plugin_runtime-0.5.7a141.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.5.7a141.dist-info/METADATA,sha256=GxlnEUYJq_OY85r6o6WB0tQUGHg1MktSjdIPpBpRg9k,1985
11
- omnata_plugin_runtime-0.5.7a141.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.5.7a141.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.5.7a145.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.5.7a145.dist-info/METADATA,sha256=CjSBdW5cKSIrQ1iKBJ3krdVJy6RHqzAAD4b2g44nik4,1985
11
+ omnata_plugin_runtime-0.5.7a145.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.5.7a145.dist-info/RECORD,,