Giter Club home page Giter Club logo

Comments (3)

CermakM avatar CermakM commented on May 31, 2024 1

@yxue-kabam whatever is set as a property to the Workflow becomes part of the WorkflowSpec if that property is valid according to the OpenAPI specification of WorkflowSpec. That being said, @brtasavpatel 's approach is correct, setting affinity property of the Workflow makes part of the workflow.spec.affinity.
Unfortunately, that particular property is really annoyingly nested :/ not much we can do here, tho, as this is the specification of it.

from argo-python-dsl.

brtasavpatel avatar brtasavpatel commented on May 31, 2024

I think I found out how to use those, this is an example below, but it seems to have a lot of nested classes which needs to be initiated just to set Affinity. Am I doing it correctly?

from argo.workflows.client import V1alpha1Api

from argo.workflows.dsl import Workflow
from argo.workflows.dsl.tasks import *
from argo.workflows.dsl.templates import *
from kubernetes.client.models import V1Toleration, V1Affinity, V1NodeAffinity, V1NodeSelector, \
    V1NodeSelectorTerm


class TestWorkflow(Workflow):
    service_account_name = 'argo-workflow'

    node_selector = V1NodeSelector(
        node_selector_terms=[
            V1NodeSelectorTerm(
                match_expressions={"key": "app", "operator": "In", "values": ["job"]}),
            V1NodeSelectorTerm(
                match_expressions={"key": "worker", "operator": "In", "values": ["default"]}),
        ])

    node_affnity = V1NodeAffinity(required_during_scheduling_ignored_during_execution=node_selector)

    affinity = V1Affinity(node_affnity)

    tolerations = [V1Toleration(
        key="app",
        operator="Equal",
        value="job",
        effect="NoSchedule"
    )]

from argo-python-dsl.

yxue-kabam avatar yxue-kabam commented on May 31, 2024

@brtasavpatel tolerations and affinity should go to top level workflow spec
see https://github.com/CermakM/argo-client-python/blob/0caa743442d37f2f2e3b30867398ed2708c1bf4d/argo/workflows/client/models/v1alpha1_workflow_spec.py#L59

you are making progress, but currently there is no direct support from the dsl that can help you set those attr directly from within the class.

Once you have the workflow object from TestWorkflow(), try this

workflow.spec.toleration = ...
workflow.spec.affinity = ...

from argo-python-dsl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.