Developing with a Local Python Registry¶
Some of the repositories of OCAI are configured to bundle all its functionality into Python libraries. By default, these libraries are uploaded into this online Space CODEV Python registry by the CI/CD pipelines. OCAI's components look for their required OCAI Python libraries in that online registry.
In some circumstances, quick code iterations are difficult if the OCAI Python libraries need to be pushed and retrieved from the online Python repository. Developers can instead use a local PyPi server to deploy and use OCAI's Python components without relying on any CI/CD pipelines or external sources.
Using a local PyPi registry¶
A local PyPi registry can be setup to distribute Python packages for local testing. In order to test changes of OCAI Core Search server or OCAI Core Knowledge Loader in OCAI, the packages built from these repositories must be used in the OCAI building process. They must be built, uploaded to a registry, the registry used as a source for the packages to be used in the docker build, finally the image must be used in the OCAI docker compose file.
Starting the server¶
A local PyPi registry server can be started using in any of those repositories (CORE or Tailoring):
make start_pypi_server
And stopped with:
make stop_pypi_server
Notice that the server will use folder ~/local-pypi to store the packages, and only 1 server is needed per machine (no need to repeat this operation for every repository).
Building the package¶
Set the build version as an enviromental variable, it can be any valid version value, as long as it is a higher version than the one currently used by OCAI, it will automatically choose the most recent one.
export VERSION="100.0.0"
The package can be built running in the desired CORE repository:
make build
It will be saved in ./dist folder and it can be uploaded to the local registry with:
make deploy_locally
Using the package¶
The package can be used by adding the PyPi server url (in this case http:localhost:12354/simple) as extra index to the pip install command, or using specific make recipes, as shown below.
Specifying latest package version¶
To use the package while building a tailoring docker image, the requirements.txt of that repository must be modified to chage the required OCAI Core package version either to the one specified during package build, or completely removing the version. Make sure the built version is the highest, it will automatically try to get the newest version.
E.g. to load OCAI Core Search Server package:
# OCAI Core
ocai-search-server
Building the image¶
The image can be built by running in the desired tailoring repository:
make build_from_local
Using the image¶
The docker image can be used in OCAI by setting in the OCAI docker-compose.yml (e.g. at ocai-starter-deployment/docker/ocai, but OCAI deployment folders might be different depending on tailoring) the built image version to latest.