INNER CODE UNIT · Python

sn

IBM/AutoMLPipeline.jl · argo-workflow/agents/argo-k8s.py:70

def sn(namespace=current_namespace_context):
    try:
        global current_namespace_context
        # First, switch the kubectl config context permanently
        subprocess.run(
            ["kubectl", "config", "set-context", "--current", "--namespace", namespace],
            capture_output=True,
            text=True,
            check=True,
        )
        logger.info(f"kubectl config switched to: {namespace}")
        current_namespace_context = namespace  # Track the current context globally
        return {"message": f"Switched to namespace: {namespace}"}
    except subprocess.CalledProcessError as cmd_error:
        logger.error(f"Error switching kubectl context: {cmd_error.stderr}")
        return {"error": f"kubectl context switch failed: {cmd_error.stderr}"}
    except Exception as e:
        logger.error(f"Error switching namespace to {namespace}: {e}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…