Packages
Listing and loading Packages.
The kxi.packages.packages
module provides all the callable functions used for
listing and loading packages.
All functionality within this module is described below.
kxi.packages.packages.list
List all packages stored at KX_PACKAGE_PATH
.
Returns:
Type | Description |
---|---|
DataFrame |
Table outlining the name and version of all packages stored at |
Examples:
List all the packages stored at KX_PACKAGE_PATH
this assumes defined packages exist prior to listing and KX_PACKAGE_PATH
is set
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> # initialize the package
>>> pakx.init()
>>> # list all packages
>>> pakx.packages.list()
name versions
1 qpackage 1.0.0
kxi.packages.packages.search
List all packages stored at KX_PACKAGE_PATH
which meet a presented search criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package_name |
str |
Regex filter string used to search for specific package name patterns.
Can also be |
None |
version |
str |
Regex filter string used to search for specific package version patterns.
Can also be |
None |
Returns:
Type | Description |
---|---|
DataFrame |
Table outlining the package name and version of all packages stored at |
Examples:
List the packages stored at KX_PACKAGE_PATH
under different search conditions
this assumes defined packages exist prior to listing and KX_PACKAGE_PATH
is set
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> # initialize the package
>>> pakx.init()
>>> # list all packages
>>> packages.list()
name versions
1 qpackage 1.0.0
2 testpkg 1.1.0
2 testpkg 2.1.0
>>> # list all "qpackage" related packages
>>> packages.search("*qpackage*")
name versions
1 qpackage 1.0.0
>>> # list all packages that are version 1.x
>>> packages.search(version="1.*")
name versions
1 qpackage 1.0.0
2 testpkg 1.1.0
kxi.packages.packages.load
Load the contents of a package.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
package_name |
str |
Name of package to be loaded. |
required |
version |
str |
Version of package to be loaded. |
required |
entry |
str |
Name of the entrypoint used when loading the package.
This is defined within the |
'default' |
path |
str |
Path to the package to be loaded.
If the value is set to |
None |
force |
bool |
Load the package regardless of whether a package with the same name and entry point has previously been loaded. |
False |
Returns:
Type | Description |
---|---|
Optional[module] |
|
Examples:
Load a package called "ml" with version "2.0.0" a package called "ml" with version "1.0.0" forcing overwrite
>>> # import the necessary modules
>>> import kxi.packages as pakx
>>> pakx.init()
>>> # list all packages
>>> packages.list()
name versions
0 ml 1.0.0
1 ml 2.0.0
>>> # load the "ml" package with version 2.0.0
>>> packages.load("ml", "2.0.0")
>>> # load the "ml" package with version 1.0.0 forcing load override
>>> packages.load("ml", "1.0.0", force=True)
kxi.packages.packages.load_file
Define a file to be loaded within a package relative to package root.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path |
str |
Relative path from package root to the file to be loaded |
required |
Returns:
Type | Description |
---|---|
None |
|
Examples:
Add the following to any Python file loaded as part of initialising a Python entrypoint
from kxi.packages import packages
# Load the file src/example_udf.py assigning output to udfs
udfs = packages.load_file("src/example_udf.py")