omnata-plugin-runtime 0.5.7a133__py3-none-any.whl → 0.5.7a135__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.
@@ -38,6 +38,7 @@ import jinja2
38
38
  import pandas
39
39
  from pydantic_core import to_jsonable_python
40
40
  from pydantic import Field, TypeAdapter, ValidationError, create_model, root_validator, BaseModel
41
+ from pydantic.dataclasses import dataclass
41
42
  from dateutil.parser import parse
42
43
  from jinja2 import Environment
43
44
  from snowflake.connector.pandas_tools import write_pandas
@@ -2228,7 +2229,25 @@ def get_nested_value(nested_dict:Dict, keys:List[str]):
2228
2229
  keys = [keys]
2229
2230
  return reduce(lambda d, key: d.get(key) if isinstance(d, dict) else None, keys, nested_dict)
2230
2231
 
2231
- def consumer_udtf(param_docs: Dict[str, Dict[str, Any]]):
2232
+
2233
+ @dataclass
2234
+ class SnowflakeFunctionParameter:
2235
+ name: str
2236
+ description: str
2237
+ data_type: str
2238
+ has_default_value: bool = False
2239
+ default_value_clause: Optional[str] = None
2240
+
2241
+ @dataclass
2242
+ class SnowflakeUDTFResultColumn:
2243
+ name: str
2244
+ data_type: str
2245
+ description: str
2246
+
2247
+ def consumer_udtf(
2248
+ description: str,
2249
+ params: List[SnowflakeFunctionParameter],
2250
+ result_columns: List[SnowflakeUDTFResultColumn]):
2232
2251
  def class_decorator(cls):
2233
2252
  # Get the original 'process' method from the class
2234
2253
  cls._is_omnata_consumer_udtf = True
@@ -2275,7 +2294,7 @@ def consumer_udtf(param_docs: Dict[str, Dict[str, Any]]):
2275
2294
 
2276
2295
  return class_decorator
2277
2296
 
2278
- def find_classes_with_attribute(attribute_name: str,path:str = '.'):
2297
+ def find_consumer_udtf_classes(path:str = '.'):
2279
2298
  # Get the directory's absolute path
2280
2299
  current_dir = os.path.abspath(path)
2281
2300
 
@@ -2290,11 +2309,15 @@ def find_classes_with_attribute(attribute_name: str,path:str = '.'):
2290
2309
  # Iterate over all members of the module
2291
2310
  for name, obj in inspect.getmembers(module, inspect.isclass):
2292
2311
  # Check if the class has the specified attribute
2293
- if hasattr(obj, attribute_name):
2312
+ if hasattr(obj, '_is_omnata_consumer_udtf'):
2294
2313
  matching_classes.append(obj)
2314
+ return matching_classes
2295
2315
 
2296
2316
 
2297
- def consumer_udf(param_docs: Dict[str, Dict[str, Any]]):
2317
+ def consumer_udf(
2318
+ description: str,
2319
+ params: List[SnowflakeFunctionParameter],
2320
+ result_data_type: str):
2298
2321
  def decorator(func):
2299
2322
  sig = signature(func)
2300
2323
  params = sig.parameters
@@ -2333,3 +2356,23 @@ def consumer_udf(param_docs: Dict[str, Dict[str, Any]]):
2333
2356
  return wrapper
2334
2357
 
2335
2358
  return decorator
2359
+
2360
+ def find_consumer_udf_functions(path:str = '.'):
2361
+ # Get the current directory's absolute path
2362
+ current_dir = os.path.abspath(path)
2363
+
2364
+ # List to hold the classes that match the attribute
2365
+ matching_classes = []
2366
+
2367
+ # Iterate over all modules in the current directory
2368
+ for _, module_name, _ in pkgutil.iter_modules([current_dir]):
2369
+ # Import the module
2370
+ module = importlib.import_module(module_name)
2371
+
2372
+ # Iterate over all members of the module
2373
+ for name, obj in inspect.getmembers(module, inspect.isfunction):
2374
+ # Check if the class has the specified attribute
2375
+ if hasattr(obj, '_is_omnata_consumer_udf'):
2376
+ matching_classes.append(obj)
2377
+
2378
+ return matching_classes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.5.7a133
3
+ Version: 0.5.7a135
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=yY2f5xE0VnzfGiL8CGyje_rVbZmCMgm6NYiaWxt-N1k,116805
6
+ omnata_plugin_runtime/omnata_plugin.py,sha256=-u_v8EboxbwkiYw6AcmeJfvuYEI7eWcQ5bSjRUeH8kg,118053
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.7a133.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
- omnata_plugin_runtime-0.5.7a133.dist-info/METADATA,sha256=hR1rJW54yER8oVdKnh8VddCA_iRFGVWVAl9VaEfCd3M,1985
11
- omnata_plugin_runtime-0.5.7a133.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
- omnata_plugin_runtime-0.5.7a133.dist-info/RECORD,,
9
+ omnata_plugin_runtime-0.5.7a135.dist-info/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
10
+ omnata_plugin_runtime-0.5.7a135.dist-info/METADATA,sha256=nGKtINdFnVmfWvG119LLVku-fh93V62sMatfuNkIU9k,1985
11
+ omnata_plugin_runtime-0.5.7a135.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
12
+ omnata_plugin_runtime-0.5.7a135.dist-info/RECORD,,