omnata-plugin-runtime 0.5.7a145__tar.gz → 0.5.7a146__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.5.7a145
3
+ Version: 0.5.7a146
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.5.7-a145"
3
+ version = "0.5.7-a146"
4
4
  description = "Classes and common runtime components for building and running Omnata Plugins"
5
5
  authors = ["James Weakley <james.weakley@omnata.com>"]
6
6
  readme = "README.md"
@@ -2259,13 +2259,14 @@ class SnowflakeUDTFResultColumn:
2259
2259
  class PythonUDTFDefinition:
2260
2260
  """
2261
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.
2262
+ Do not use this class directly in plugins, instead use the omnata_udtf decorator.
2263
2263
  """
2264
2264
  name: str
2265
2265
  description: str
2266
2266
  params: List[SnowflakeFunctionParameter]
2267
2267
  result_columns: List[SnowflakeUDTFResultColumn]
2268
2268
  handler: str
2269
+ expose_to_consumer: bool
2269
2270
  packages: Optional[List[str]] = None
2270
2271
 
2271
2272
  def __str__(self):
@@ -2317,13 +2318,14 @@ HANDLER='{self.handler}';
2317
2318
  class PythonUDFDefinition:
2318
2319
  """
2319
2320
  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
+ Do not use this class directly in plugins, instead use the omnata_udf decorator.
2321
2322
  """
2322
2323
  name: str
2323
2324
  description: str
2324
2325
  params: List[SnowflakeFunctionParameter]
2325
2326
  result_data_type: str
2326
2327
  handler: str
2328
+ expose_to_consumer: bool
2327
2329
  packages: Optional[List[str]] = None
2328
2330
 
2329
2331
  def __str__(self):
@@ -2351,6 +2353,7 @@ class JavaUDFDefinition:
2351
2353
  packages: List[str]
2352
2354
  imports: List[str]
2353
2355
  handler: str
2356
+ expose_to_consumer: bool
2354
2357
 
2355
2358
  def __str__(self):
2356
2359
  param_str = ', '.join([str(param) for param in self.params])
@@ -2366,13 +2369,14 @@ IMPORTS = ({imports_str})
2366
2369
  HANDLER='{self.handler}';
2367
2370
  """
2368
2371
 
2369
- def consumer_udtf(
2372
+ def omnata_udtf(
2370
2373
  name:str,
2371
2374
  description: str,
2372
2375
  params: List[SnowflakeFunctionParameter],
2373
- result_columns: List[SnowflakeUDTFResultColumn]):
2376
+ result_columns: List[SnowflakeUDTFResultColumn],
2377
+ expose_to_consumer: bool):
2374
2378
  """
2375
- A decorator for a class which should be automatically exposed to the consumer as a UDTF
2379
+ A decorator for a class which should create a UDTF in the UDFS schema of the native app
2376
2380
  """
2377
2381
  def class_decorator(cls):
2378
2382
  # Get the original 'process' method from the class
@@ -2420,18 +2424,19 @@ def consumer_udtf(
2420
2424
  return original_process(self, parameters, *args, **kwargs)
2421
2425
  # Replace the original 'process' method with the wrapped version
2422
2426
  setattr(cls, 'process', wrapped_process)
2423
- cls._is_omnata_consumer_udtf = True
2424
- cls._omnata_consumer_udtf_name = name
2425
- cls._omnata_consumer_udtf_description = description
2426
- cls._omnata_consumer_udtf_params = params
2427
- cls._omnata_consumer_udtf_result_columns = result_columns
2427
+ cls._is_omnata_udtf = True
2428
+ cls._omnata_udtf_name = name
2429
+ cls._omnata_udtf_description = description
2430
+ cls._omnata_udtf_params = params
2431
+ cls._omnata_udtf_result_columns = result_columns
2432
+ cls._omnata_udtf_expose_to_consumer = expose_to_consumer
2428
2433
  return cls
2429
2434
 
2430
2435
  return class_decorator
2431
2436
 
2432
- def find_consumer_udtf_classes(path:str = '.') -> List[PythonUDTFDefinition | JavaUDTFDefinition]:
2437
+ def find_udtf_classes(path:str = '.') -> List[PythonUDTFDefinition | JavaUDTFDefinition]:
2433
2438
  """
2434
- Finds all classes in the specified directory which have the 'consumer_udtf' decorator applied
2439
+ Finds all classes in the specified directory which have the 'omnata_udtf' decorator applied
2435
2440
  """
2436
2441
  # Get the directory's absolute path
2437
2442
  current_dir = os.path.abspath(path)
@@ -2447,12 +2452,13 @@ def find_consumer_udtf_classes(path:str = '.') -> List[PythonUDTFDefinition | Ja
2447
2452
  # Iterate over all members of the module
2448
2453
  for name, obj in inspect.getmembers(module, inspect.isclass):
2449
2454
  # Check if the class has the specified attribute
2450
- if hasattr(obj, '_is_omnata_consumer_udtf'):
2455
+ if hasattr(obj, '_is_omnata_udtf'):
2451
2456
  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,
2457
+ name=obj._omnata_udtf_name,
2458
+ description=obj._omnata_udtf_description,
2459
+ params=obj._omnata_udtf_params,
2460
+ result_columns=obj._omnata_udtf_result_columns,
2461
+ expose_to_consumer=obj._omnata_udtf_expose_to_consumer,
2456
2462
  handler=obj.__module__+'.'+obj.__name__
2457
2463
  ))
2458
2464
  elif isinstance(obj, JavaUDTFDefinition):
@@ -2461,11 +2467,12 @@ def find_consumer_udtf_classes(path:str = '.') -> List[PythonUDTFDefinition | Ja
2461
2467
  return matching_classes
2462
2468
 
2463
2469
 
2464
- def consumer_udf(
2470
+ def omnata_udf(
2465
2471
  name: str,
2466
2472
  description: str,
2467
2473
  params: List[SnowflakeFunctionParameter],
2468
- result_data_type: str):
2474
+ result_data_type: str,
2475
+ expose_to_consumer: bool):
2469
2476
  """
2470
2477
  A decorator for a function which should be automatically exposed to the consumer as a UDF
2471
2478
  """
@@ -2505,18 +2512,19 @@ def consumer_udf(
2505
2512
  # Pass the validated arguments to the function
2506
2513
  return func(parameters, *args, **kwargs)
2507
2514
 
2508
- wrapper._is_omnata_consumer_udf = True
2509
- wrapper._omnata_consumer_udf_name = name
2510
- wrapper._omnata_consumer_udf_description = description
2511
- wrapper._omnata_consumer_udf_params = params
2512
- wrapper._omnata_consumer_udf_result_data_type = result_data_type
2515
+ wrapper._is_omnata_udf = True
2516
+ wrapper._omnata_udf_name = name
2517
+ wrapper._omnata_udf_description = description
2518
+ wrapper._omnata_udf_params = params
2519
+ wrapper._omnata_udf_result_data_type = result_data_type
2520
+ wrapper._omnata_udf_expose_to_consumer = expose_to_consumer
2513
2521
  return wrapper
2514
2522
 
2515
2523
  return decorator
2516
2524
 
2517
- def find_consumer_udf_functions(path:str = '.') -> List[PythonUDFDefinition | JavaUDFDefinition]:
2525
+ def find_udf_functions(path:str = '.') -> List[PythonUDFDefinition | JavaUDFDefinition]:
2518
2526
  """
2519
- Finds all functions in the specified directory which have the 'consumer_udf' decorator applied
2527
+ Finds all functions in the specified directory which have the 'omnata_udf' decorator applied
2520
2528
  """
2521
2529
  # Get the current directory's absolute path
2522
2530
  current_dir = os.path.abspath(path)
@@ -2532,12 +2540,13 @@ def find_consumer_udf_functions(path:str = '.') -> List[PythonUDFDefinition | Ja
2532
2540
  # Iterate over all members of the module
2533
2541
  for name, obj in inspect.getmembers(module, inspect.isfunction):
2534
2542
  # Check if the class has the specified attribute
2535
- if hasattr(obj, '_is_omnata_consumer_udf'):
2543
+ if hasattr(obj, '_is_omnata_udf'):
2536
2544
  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,
2545
+ name=obj._omnata_udf_name,
2546
+ description=obj._omnata_udf_description,
2547
+ params=obj._omnata_udf_params,
2548
+ result_data_type=obj._omnata_udf_result_data_type,
2549
+ expose_to_consumer=obj._omnata_udf_expose_to_consumer,
2541
2550
  packages=[],
2542
2551
  handler=obj.__module__+'.'+obj.__name__
2543
2552
  ))