<jupyter_start><jupyter_text>CREATE PREDICT SERVICE<jupyter_code>config.load_incluster_config()

v1 = client.CoreV1Api()

service = client.V1Service()
service.metadata = client.V1ObjectMeta(name="predict")

spec = client.V1ServiceSpec()
spec.type="LoadBalancer"
spec.selector = {"component" : "predict"}

ports = client.V1ServicePort(port=5000, target_port=5000)
spec.ports = [ports]

service.spec = spec

v1.create_namespaced_service(namespace="kubeyard", body=service)<jupyter_output><empty_output><jupyter_text>CREATE PREDICT POD<jupyter_code>config.load_incluster_config()

v1 = client.CoreV1Api()

pod = client.V1Pod()
spec = client.V1PodSpec()
pod.metadata = client.V1ObjectMeta(name="predict", labels={"component" : "predict"})

container = client.V1Container()
container.image = "registry.inovex.de:4567/inovex-kubeyard/docker-jupyter:latest"
container.args = ["/bin/bash", "-c", "gsutil cp gs://jupyter-storage/<path-in-gcs>/predict-service.py . && ipython -- predict-service.py"]
container.name = "predict"
container.ports = [client.V1ContainerPort(container_port=5000)]

spec.containers = [container]
pod.spec = spec

v1.create_namespaced_pod(namespace="kubeyard", body=pod)<jupyter_output><empty_output><jupyter_text>GET SERVICE ENDPOINT<jupyter_code>config.load_incluster_config()

v1 = client.CoreV1Api()
response = v1.read_namespaced_service(name="predict", namespace="kubeyard")

print(response.status.load_balancer.ingress[0].ip + ":" + str(response.spec.ports[0].port))<jupyter_output><empty_output><jupyter_text>DELETE PREDICT SERVICE AND POD<jupyter_code>config.load_incluster_config()

v1 = client.CoreV1Api()

#v1.delete_namespaced_pod(name="predict", namespace="kubeyard", body=client.V1DeleteOptions())
v1.delete_namespaced_service(name="predict", namespace="kubeyard")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14810751508502468, 'fraction_numerical': 0.022490400438837082, 'mean_word_length': 8.702127659574469, 'pattern_counts': {'":': 1, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '145250', 'license': 'Apache-2.0', 'n_tokens_mistral': 689, 'n_tokens_neox': 664, 'n_words': 78, 'path': 'docker/docker-jupyter/utils/create_predict.ipynb', 'repo_name': 'inovex/open-kubeyard', 'size': '1823'}