This is the repository for online deployment of the LCLS CU Injector ML Model. It's still under development.
It was created using the lume-model-deployment-template using copier
.
First set up kubectl by following the instructions in this link. To see the deployment logs of the container, you can use the following commands to get the name of the pod that's running, and then view the logs:
kubectl get pods
kubectl logs -f <pod-name>
To deploy the Docker image on Kubernetes, follow these steps. If you have updated the tag,
make sure to replace <tag>
with the new tag in the commands below, and in the deployment YAML file.
- Ensure you have Docker installed and running on your machine.
- Update the
deployment.yaml
file with the correct image tag and registry information, if that information has changed. - Build the Docker image. The
platform
tag is necessary if you are developing on a machine with a different architecture. If you are NOT building on a MacOS machine, you can skip the--provenance
flag.docker build -t <image-name>:<tag> . --platform=linux/amd64 --provenance=false
- Push the Docker image to the Stanford Container Registry (replace
<your-username>
with your actual username):cat ~/.scr-token | docker login --username $USER --password-stdin http://scr.svc.stanford.edu docker tag <image-name>:<tag> scr.svc.stanford.edu/<your-username>/<image-name>:<tag> docker push scr.svc.stanford.edu/<your-username>/<image-name>:<tag>
For more detailed instructions, refer to this documentation.
- To set up kubectl, follow this link. Update the Kubernetes deployment with the new image:
kubectl apply -f deployment.yaml
Once the image is deployed, you can access following these steps:
-
List all pods to find the name of the pod running the image:
kubectl get pods
-
Use the following command to access the pod:
kubectl exec -ti <pod-name> -- bash
-
Once inside the pod, you can run the Python scripts or other commands as needed. To run the tests, you can run for example (make sure you're in src/ directory):
python -m <python_script>
or
pytest tests/test.py -s -rsx -v
If you want to edit the code, you can use a text editor like
vim
to modify the files directly within the pod. For example if you want to edit a file to write/not write to PV:apt update && apt install vim vi tests/test.py