Skip to content

slaclab/lcls-cu-inj-model-deployment

Repository files navigation

LCLS CU Injector ML Model Deployment

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.

To check deployment

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>

Docker image deployment on Kubernetes (S3DF)

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.

  1. Ensure you have Docker installed and running on your machine.
  2. Update the deployment.yaml file with the correct image tag and registry information, if that information has changed.
  3. 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
  4. 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.

  1. To set up kubectl, follow this link. Update the Kubernetes deployment with the new image:
    kubectl apply -f deployment.yaml

Accessing the deployed image

Once the image is deployed, you can access following these steps:

  1. List all pods to find the name of the pod running the image:

    kubectl get pods
  2. Use the following command to access the pod:

    kubectl exec -ti <pod-name> -- bash
  3. 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

About

Repository for online deployment of the LCLS Cu Injector ML Model

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages