示例#1
0
 def sequential(cls, task):
   """Add a constraint that makes all processes within a task run sequentially."""
   def maybe_constrain(task):
     return {'constraints': order(*task.processes())} if task.processes() is not Empty else {}
   if task.constraints() is Empty or task.constraints() == List(Constraint)([]):
     return task(**maybe_constrain(task))
   raise ValueError('Cannot turn a Task with existing constraints into a SequentialTask!')
示例#2
0
class Task(Struct):
    name = Default(String, '{{processes[0].name}}')
    processes = List(Process)

    # optionals
    constraints = Default(List(Constraint), [])
    resources = Resources
    max_failures = Default(
        Integer,
        1)  # maximum number of failed processes before task is failed.
    max_concurrency = Default(Integer, 0)  # 0 is infinite concurrency.
    # > 0 is max concurrent processes.
    finalization_wait = Default(
        Integer, 30)  # the amount of time in seconds we allocate to run the
    # finalization schedule.

    # TODO(jon): remove/replace with proper solution to MESOS-3546
    user = String
示例#3
0
def test_choice_primlist():
  """Test that choices with a list value work correctly."""
  C = Choice([String, List(Integer)])
  c = C([1, 2, 3])
  assert c.check().ok()
  c = C("hello")
  assert c.check().ok()
  c = C([1, 2, "{{x}}"])
  assert not c.check().ok()
  assert c.bind(x=3).check().ok()
示例#4
0
def test_repr():
    class Dumb(Struct):
        one = String

    class ChoiceDefaultStruct(Struct):
        a = Default(Choice("IntOrDumb", [Dumb, Integer]), 28)
        b = Integer

    class OtherStruct(Struct):
        first = ChoiceDefaultStruct
        second = String

    C = Choice([String, List(Integer)])

    testvalone = C("hello")
    testvaltwo = C([1, 2, 3])
    assert repr(testvalone) == "Choice_String_IntegerList('hello')"
    assert repr(testvaltwo) == "Choice_String_IntegerList([1, 2, 3])"
class ZkAuth(Struct):
    auth = Default(List(Auth), [])
    acl = Default(List(Access), [])
示例#6
0
 class Qux(Struct):
     item = Choice([String, List(Item)])
示例#7
0
class Constraint(Struct):
    order = List(String)