omnata-plugin-runtime 0.5.7a138__tar.gz → 0.5.7a140__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.7a138
3
+ Version: 0.5.7a140
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-a138"
3
+ version = "0.5.7-a140"
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"
@@ -2232,22 +2232,36 @@ def get_nested_value(nested_dict:Dict, keys:List[str]):
2232
2232
 
2233
2233
  @dataclass
2234
2234
  class SnowflakeFunctionParameter:
2235
+ """
2236
+ Represents a parameter for a Snowflake UDF or UDTF
2237
+ """
2235
2238
  name: str
2236
2239
  description: str
2237
2240
  data_type: str
2238
- has_default_value: bool = False
2239
2241
  default_value_clause: Optional[str] = None
2240
2242
 
2243
+ def __str__(self):
2244
+ if self.default_value_clause:
2245
+ return f"{self.name} {self.data_type} default {self.default_value_clause}"
2246
+ return f"{self.name} {self.data_type}"
2247
+
2241
2248
  @dataclass
2242
2249
  class SnowflakeUDTFResultColumn:
2250
+ """
2251
+ Represents a result column for a Snowflake UDTF
2252
+ """
2243
2253
  name: str
2244
2254
  data_type: str
2245
2255
  description: str
2246
2256
 
2247
2257
  def consumer_udtf(
2258
+ name:str,
2248
2259
  description: str,
2249
2260
  params: List[SnowflakeFunctionParameter],
2250
2261
  result_columns: List[SnowflakeUDTFResultColumn]):
2262
+ """
2263
+ A decorator for a class which should be automatically exposed to the consumer as a UDTF
2264
+ """
2251
2265
  def class_decorator(cls):
2252
2266
  # Get the original 'process' method from the class
2253
2267
  original_process = getattr(cls, 'process')
@@ -2295,6 +2309,7 @@ def consumer_udtf(
2295
2309
  # Replace the original 'process' method with the wrapped version
2296
2310
  setattr(cls, 'process', wrapped_process)
2297
2311
  cls._is_omnata_consumer_udtf = True
2312
+ cls._omnata_consumer_udtf_name = name
2298
2313
  cls._omnata_consumer_udtf_description = description
2299
2314
  cls._omnata_consumer_udtf_params = params
2300
2315
  cls._omnata_consumer_udtf_result_columns = result_columns
@@ -2303,6 +2318,9 @@ def consumer_udtf(
2303
2318
  return class_decorator
2304
2319
 
2305
2320
  def find_consumer_udtf_classes(path:str = '.'):
2321
+ """
2322
+ Finds all classes in the specified directory which have the 'consumer_udtf' decorator applied
2323
+ """
2306
2324
  # Get the directory's absolute path
2307
2325
  current_dir = os.path.abspath(path)
2308
2326
 
@@ -2323,9 +2341,13 @@ def find_consumer_udtf_classes(path:str = '.'):
2323
2341
 
2324
2342
 
2325
2343
  def consumer_udf(
2344
+ name: str,
2326
2345
  description: str,
2327
2346
  params: List[SnowflakeFunctionParameter],
2328
2347
  result_data_type: str):
2348
+ """
2349
+ A decorator for a function which should be automatically exposed to the consumer as a UDF
2350
+ """
2329
2351
  def decorator(func):
2330
2352
  sig = signature(func)
2331
2353
  function_params = sig.parameters
@@ -2363,6 +2385,7 @@ def consumer_udf(
2363
2385
  return func(parameters, *args, **kwargs)
2364
2386
 
2365
2387
  wrapper._is_omnata_consumer_udf = True
2388
+ wrapper._omnata_consumer_udf_name = name
2366
2389
  wrapper._omnata_consumer_udf_description = description
2367
2390
  wrapper._omnata_consumer_udf_params = params
2368
2391
  wrapper._omnata_consumer_udf_result_data_type = result_data_type
@@ -2371,6 +2394,9 @@ def consumer_udf(
2371
2394
  return decorator
2372
2395
 
2373
2396
  def find_consumer_udf_functions(path:str = '.'):
2397
+ """
2398
+ Finds all functions in the specified directory which have the 'consumer_udf' decorator applied
2399
+ """
2374
2400
  # Get the current directory's absolute path
2375
2401
  current_dir = os.path.abspath(path)
2376
2402