Beispiel #1
0
import kubernetes
import yaml
from argo.workflows import config
from argo.workflows.client import V1alpha1Api
from flask import Blueprint, jsonify, request
from kubernetes.client.rest import ApiException
from kubernetes import client, config as kubernetes_config
from nevermined_sdk_py import Nevermined, Config

from nevermined_compute_api.workflow_utils import setup_keeper, create_execution

services = Blueprint('services', __name__)

# Configuration to connect to k8s.
if not path.exists('/.dockerenv'):
    config.load_kube_config()
    kubernetes_config.load_kube_config()
else:
    config.load_incluster_config()
    kubernetes_config.load_incluster_config()

# create instance of the API class
v1alpha1 = V1alpha1Api()
# create instance of the kubernetes client
kubernetes_client = client.CoreV1Api()

config_parser = ConfigParser()
configuration = config_parser.read('config.ini')
group = config_parser.get('resources',
                          'group')  # str | The custom resource's group name
version = config_parser.get('resources',
Beispiel #2
0
import requests
import pytest
import yaml
from argo.workflows.client import V1alpha1Api
from argo.workflows.config import load_kube_config

NAMESPACE = "argo"
ARGO_VERSION = open("ARGO_VERSION").read()

load_kube_config()  # loads local configuration from ~/.kube/config

RESUBMIT_WORKFLOW_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/resubmit.yaml'
RETRY_BACKOFF_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/retry-backoff.yaml'
RETRY_CONTAINER_TO_COMPLETION_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/retry-container-to-completion.yaml'
RETRY_CONTAINER_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/retry-container.yaml'
RETRY_ON_ERROR_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/retry-on-error.yaml'
RETRY_SCRIPT_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/retry-script.yaml'
RETRY_WITH_STEPS_YML = f'https://raw.githubusercontent.com/argoproj/argo/v{ARGO_VERSION}/examples/retry-with-steps.yaml'


def test_resubmit_workflow():
    resp = requests.get(RESUBMIT_WORKFLOW_YML)
    resp.raise_for_status()

    manifest: dict = yaml.safe_load(resp.text)
    v1alpha1 = V1alpha1Api()
    v1alpha1.create_namespaced_workflow(NAMESPACE, manifest)


def test_retry_backoff_workflow():
    resp = requests.get(RETRY_BACKOFF_YML)