This Python library contains the non-service-specific code that can be used by NWDAF microservices.
To build this project, only one pre-requisite is needed:
- Python ≥ 3.12 (preferably in a virtualenv, or using Conda)
This tutorial has been tested with WSL, and Ubuntu 24.04.1 (Noble Numbat) and assumes the user has some basic knowledge of Unix command line interfaces.
In the virtualenv, install the build package:
pip install buildThen, to build the Python package, you can simply run this script from the root of the repository:
./build.sh [-v|--version <version_number>]- The
-vor--versionoption can be used to specify the version number of the Python package
This script will build the .tar.gz and .whl package files with the provided version number.
After building the package, you can simply install it in your environment using pip :
pip install .After that, you will be able to import the generated model classes in your Python code.
⚠️ Please note the following code will only work if you have a Kafka server listening on kafka-server:9092. For a standalone example to just test the import of the library, see example #2
from nwdaf_libcommon.ApiGatewayService import ApiGatewayService
from nwdaf_api.models.nf_type import NFType
# This API Gateway service will listen to incoming requests on port 5000, and will be able to handle GMLC and RAN event exposures
service = ApiGatewayService("api-gateway", 5000, "kafka-server:9092", {NFType.GMLC, NFType.RAN})
# Initialize the NF registry with IP/FQDN and ports used by NF event exposure services
service.init_nf_registry([(NFType.GMLC, "192.168.1.10", 6000),
(NFType.RAN, "192.168.1.20", 7000)])
# Run the service
if __name__ == '__main__':
service.run()from nwdaf_libcommon.NfRegistry import NfRegistry
from nwdaf_api.models.nf_type import NFType
# Define a list of NF information
nf_info = [(NFType.GMLC, "192.168.1.10", 6000), (NFType.RAN, "192.168.1.20", 7000)]
# Initialize the NF Registry with IP/FQDN and ports used by NF event exposure services
registry = NfRegistry()
for nf in nf_info:
registry.add_nf_config(nf[0], nf[1], nf[2])
# Get the GMLC event exposure URI and print it in the standard output
gmlc_info = registry.get_nf_config(NFType.GMLC)
print(f"GMLC information: {gmlc_info.get_event_exposure_uri()}")