User Defined Functions
Listing and loading User-Defined Functions.
The kxi.packages.udfs
module provides all the callable functions used for
listing and loading user-defined functions.
All functionality within this module is described below.
kxi.packages.udfs.__all__ = ['list_udfs_in_file', 'list_udfs_in_folder', 'list', 'search', 'load']
module-attribute
kxi.packages.udfs.__dir__
kxi.packages.udfs.list_udfs_in_file
List all the UDFs defined in a specific file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the file that is to be searched for UDFs. Can be an absolute or relative path. |
required |
udf_sym |
str
|
Symbol to be used to distinguish udfs |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
Table outlining all the UDFs defined within the specified file. |
Examples:
List a summary of all the UDFs defined within a specified file
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> pakx.init()
>>> # list all UDFs in the file "test/test-packages/ml/1.0.0/ml.q"
>>> pakx.udfs.list_udfs_in_file("test/test-packages/ml/1.0.0/ml.q")
name function language file_path ...
0 ml_udf .test.test_udf q test/test-packages/ml/1.0.0/ml.q ...
kxi.packages.udfs.list_udfs_in_folder
List all the UDFs defined in the files within a specific folder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the folder that is to be searched for UDFs. Can be an absolute or relative path. |
required |
udf_sym |
str
|
Symbol to be used to distinguish udfs |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
Table outlining all the UDFs defined within the files in the specified folder. |
Examples:
List a summary of all the UDFs defined within the files in a specified folder
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> # initialize the package
>>> pakx.init()
>>> # list all UDFs in the "test/test-packages/ml" folder
>>> pakx.udfs.list_udfs_in_folder("test/test-packages/ml")
name function language file_path ...
0 ml_udf .test.test_udf q test/test-packages/ml/1.0.0/ml.q ...
1 py_udf func py test/test-packages/ml/1.0.0/src/test.py ...
2 map_udf .test.map_udf q test/test-packages/ml/1.0.0/src/test1.q ...
3 filter_udf .test.filter_udf q test/test-packages/ml/1.0.0/src/test1.q ...
4 merge_udf .test.merge_udf q test/test-packages/ml/1.0.0/src/test1.q ...
. ... ... ... ... ...
. ... ... ... ... ...
kxi.packages.udfs.list
List all the UDFs defined at the path under KX_PACKAGE_PATH
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
udf_syms |
List[str]
|
Symbols to be used to distinguish udfs |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
Table outlining all the UDFs defined under |
Examples:
List a summary of all UDFs defined under KX_PACKAGE_PATH
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> # initialize the package
>>> pakx.init()
>>> # list all UDFs defined under `KX_PACKAGE_PATH`
>>> udfs.list()
name function language file_path ...
0 ml_udf .test.test_udf q test/test-packages/ml/1.0.0/ml.q ...
1 py_udf func py test/test-packages/ml/1.0.0/src/test.py ...
2 map_udf .test.map_udf q test/test-packages/ml/1.0.0/src/test1.q ...
3 filter_udf .test.filter_udf q test/test-packages/ml/1.0.0/src/test1.q ...
4 merge_udf .test.merge_udf q test/test-packages/ml/1.0.0/src/test1.q ...
. ... ... ... ... ...
. ... ... ... ... ...
kxi.packages.udfs.search
List all UDFs defined under KX_PACKAGE_PATH
that match a presented search criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
udf_name |
str
|
Regex filter string used to search for specific UDF name patterns.
Can also be |
None
|
package_name |
str
|
Regex filter string used to search for specific package name patterns.
Can also be |
None
|
package_version |
str
|
Regex filter string used to search for specific package version patterns.
Can also be |
None
|
udf_syms |
List[str]
|
Symbols to be used to distinguish udfs |
None
|
Returns:
Type | Description |
---|---|
pd.DataFrame
|
Table outlining all the UDFs defined under |
pd.DataFrame
|
search criteria. |
Examples:
List a summary of all UDFs defined under KX_PACKAGE_PATH
which match the presented
search criteria
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> # initialize the package
>>> pakx.init()
>>> # list all UDFs defined under `KX_PACKAGE_PATH`
>>> udfs.search()
name function language file_path ...
0 ml_udf .test.test_udf q test/test-packages/ml/1.0.0/ml.q ...
1 py_udf func py test/test-packages/ml/1.0.0/src/test.py ...
2 map_udf .test.map_udf q test/test-packages/ml/1.0.0/src/test1.q ...
3 filter_udf .test.filter_udf q test/test-packages/ml/1.0.0/src/test1.q ...
4 merge_udf .test.merge_udf q test/test-packages/ml/1.0.0/src/test1.q ...
. ... ... ... ... ...
. ... ... ... ... ...
>>> # search for all UDFs associated with the "ml" package
>>> udfs.search(package_name="*ml*")
name function language file_path ...
0 ml_udf .test.test_udf q test/test-packages/ml/1.0.0/ml.q ...
1 py_udf func py test/test-packages/ml/1.0.0/src/test.py ...
2 map_udf .test.map_udf q test/test-packages/ml/1.0.0/src/test1.q ...
3 filter_udf .test.filter_udf q test/test-packages/ml/1.0.0/src/test1.q ...
4 merge_udf .test.merge_udf q test/test-packages/ml/1.0.0/src/test1.q ...
. ... ... ... ... ...
. ... ... ... ... ...
>>> # search for all UDFs that start with the letter "m"
>>> udfs.search("m*")
name function language file_path
0 ml_udf .test.test_udf q test/test-packages... ...
2 map_udf .test.map_udf q test/test-packages/ml/1.0... ...
4 merge_udf .test.merge_udf q test/test-packages/ml/1.0... ...
3 myudf .test.sub_namespace.test_udf q test/test-packages... ...
4 my_udf .ml.testing.func q test/test-packages/ml/2... ...
. ... ... ... ... ...
. ... ... ... ... ...
kxi.packages.udfs.load
Load a UDF into memory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
udf_name |
str
|
Name of the UDF to be loaded. |
required |
package_name |
str
|
Name of the package from which to load the UDF. |
required |
package_version |
str
|
Version of the package from which to load the UDF.
Can also be |
None
|
udf_syms |
List[str]
|
Symbols of udf to be loaded |
None
|
force |
bool
|
Load a UDF regardless of whether a UDF of the same name has been loaded previously within a different version of the package. |
False
|
Returns:
Type | Description |
---|---|
None
|
User-defined function as a callable function. |
Examples:
List a summary of all the UDFs defined within the files in a specified folder
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> # initialize the package
>>> pakx.init()
>>> # list all UDFs defined under `KX_PACKAGE_PATH`
>>> udfs.list()
name function language file_path ...
0 ml_udf .test.test_udf q test/test-packages/ml/1.0.0/ml.q ...
1 py_udf func py test/test-packages/ml/1.0.0/src/test.py ...
2 map_udf .test.map_udf q test/test-packages/ml/1.0.0/src/test1.q ...
3 filter_udf .test.filter_udf q test/test-packages/ml/1.0.0/src/test1.q ...
4 merge_udf .test.merge_udf q test/test-packages/ml/1.0.0/src/test1.q ...
. ... ... ... ... ...
. ... ... ... ... ...
>>> # load the UDF "my_udf" from the "ml" package
>>> pakx.udfs.load("my_udf", "ml")
>>> # load the UDF "test" from the "1.2.0" version of the "test" package
>>> udfs.load("test", "test", "1.2.0")
>>> # load the UDF "py_udf" from multiple versions of the package "test_package"
>>> udf1: udfs.load("py_udf", "test_package", "1.0.0")
>>> udf2: udfs.load("py_udf", "test_package", "1.1.0", force=True)