omnata-plugin-runtime 0.5.7a139__tar.gz → 0.5.7a141__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: omnata-plugin-runtime
3
- Version: 0.5.7a139
3
+ Version: 0.5.7a141
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-a139"
3
+ version = "0.5.7-a141"
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"
@@ -6,6 +6,7 @@ Includes data container classes and defines the contract for a plugin.
6
6
  from __future__ import annotations
7
7
  from inspect import signature
8
8
  import sys
9
+ from types import FunctionType
9
10
  from typing import Union
10
11
  if tuple(sys.version_info[:2]) >= (3, 9):
11
12
  # Python 3.9 and above
@@ -2232,13 +2233,24 @@ def get_nested_value(nested_dict:Dict, keys:List[str]):
2232
2233
 
2233
2234
  @dataclass
2234
2235
  class SnowflakeFunctionParameter:
2236
+ """
2237
+ Represents a parameter for a Snowflake UDF or UDTF
2238
+ """
2235
2239
  name: str
2236
2240
  description: str
2237
2241
  data_type: str
2238
2242
  default_value_clause: Optional[str] = None
2239
2243
 
2244
+ def __str__(self):
2245
+ if self.default_value_clause:
2246
+ return f"{self.name} {self.data_type} default {self.default_value_clause}"
2247
+ return f"{self.name} {self.data_type}"
2248
+
2240
2249
  @dataclass
2241
2250
  class SnowflakeUDTFResultColumn:
2251
+ """
2252
+ Represents a result column for a Snowflake UDTF
2253
+ """
2242
2254
  name: str
2243
2255
  data_type: str
2244
2256
  description: str
@@ -2248,6 +2260,9 @@ def consumer_udtf(
2248
2260
  description: str,
2249
2261
  params: List[SnowflakeFunctionParameter],
2250
2262
  result_columns: List[SnowflakeUDTFResultColumn]):
2263
+ """
2264
+ A decorator for a class which should be automatically exposed to the consumer as a UDTF
2265
+ """
2251
2266
  def class_decorator(cls):
2252
2267
  # Get the original 'process' method from the class
2253
2268
  original_process = getattr(cls, 'process')
@@ -2303,7 +2318,10 @@ def consumer_udtf(
2303
2318
 
2304
2319
  return class_decorator
2305
2320
 
2306
- def find_consumer_udtf_classes(path:str = '.'):
2321
+ def find_consumer_udtf_classes(path:str = '.') -> List[type]:
2322
+ """
2323
+ Finds all classes in the specified directory which have the 'consumer_udtf' decorator applied
2324
+ """
2307
2325
  # Get the directory's absolute path
2308
2326
  current_dir = os.path.abspath(path)
2309
2327
 
@@ -2328,6 +2346,9 @@ def consumer_udf(
2328
2346
  description: str,
2329
2347
  params: List[SnowflakeFunctionParameter],
2330
2348
  result_data_type: str):
2349
+ """
2350
+ A decorator for a function which should be automatically exposed to the consumer as a UDF
2351
+ """
2331
2352
  def decorator(func):
2332
2353
  sig = signature(func)
2333
2354
  function_params = sig.parameters
@@ -2373,7 +2394,10 @@ def consumer_udf(
2373
2394
 
2374
2395
  return decorator
2375
2396
 
2376
- def find_consumer_udf_functions(path:str = '.'):
2397
+ def find_consumer_udf_functions(path:str = '.') -> List[function]:
2398
+ """
2399
+ Finds all functions in the specified directory which have the 'consumer_udf' decorator applied
2400
+ """
2377
2401
  # Get the current directory's absolute path
2378
2402
  current_dir = os.path.abspath(path)
2379
2403