当前位置: 首页>>代码示例>>Python>>正文


Python schema.Task类代码示例

本文整理汇总了Python中apache.thermos.config.schema.Task的典型用法代码示例。如果您正苦于以下问题:Python Task类的具体用法?Python Task怎么用?Python Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Task类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_combine_tasks

def test_combine_tasks():
  p1 = Process(name='p1')
  p2 = Process(name='p2')
  p3 = Process(name='p3')
  p4 = Process(name='p4')
  r100 = Resources(cpu=1, ram=0, disk=0)
  r010 = Resources(cpu=0, ram=1, disk=0)
  r001 = Resources(cpu=0, ram=0, disk=1)
  r111 = Units.resources_sum(r100, r010, r001)

  t1 = Task(name="p1p2", processes=[p1, p2], constraints=order(p1, p2),
            resources=Units.resources_sum(r100, r010))
  t2 = Task(name="p3p4", processes=[p3, p4], constraints=order(p3, p4),
            resources=r001)

  assert combine_tasks() == Task()
  assert combine_tasks(t1) == t1
  assert combine_tasks(t2) == t2

  t3 = combine_tasks(t1, t2)
  assert t3.name() == t2.name()
  assert t3.resources() == r111
  assert set(t3.processes()) == set([p1, p2, p3, p4])
  assert set(t3.constraints()) == set(order(p1, p2) + order(p3, p4))

  t4 = concat_tasks(t1, t2)
  assert t4.name() == t2.name()
  assert t4.resources() == r111
  assert set(t4.processes()) == set([p1, p2, p3, p4])
  assert set(t4.constraints()) == set(
      order(p1, p2) + order(p3, p4) + order(p1, p3) + order(p1, p4) +
      order(p2, p3) + order(p2, p4))
开发者ID:MustafaOrkunAcar,项目名称:incubator-aurora,代码行数:32,代码来源:test_schema.py

示例2: task

 def task(cls):
   main = Process(name="main", cmdline="date && echo hello world")
   finalizer = Process(name="finalizer", cmdline="date", final=True)
   task = Task(name="task_with_finalizer",
               processes=[main, finalizer(name='finalizer1'), finalizer(name='finalizer2')],
               constraints=[Constraint(order=['finalizer1', 'finalizer2'])])
   return task.interpolate()[0]
开发者ID:MustafaOrkunAcar,项目名称:incubator-aurora,代码行数:7,代码来源:test_finalization.py

示例3: task

 def task(cls):
   task = Task(
       name="task_with_ephemeral",
       processes=[
         Process(name="ephemeral_sleepy", ephemeral=True, cmdline="sleep 10"),
         Process(name="sleepy", cmdline="sleep 1")
       ])
   return task.interpolate()[0]
开发者ID:AltanAlpay,项目名称:aurora,代码行数:8,代码来源:test_ephemerals.py

示例4: task

 def task(cls):
   base = Process(max_failures=2, min_duration=1)
   ex = base(cmdline="exit 1")
   hw = base(cmdline="echo hello world")
   task = Task(
     name = "failing_task",
     resources = Resources(cpu = 1.0, ram = 16*1024*1024, disk = 16*1024),
     max_failures = 0,
     processes = [ex(name='f1'), ex(name='f2'), ex(name='f3'),
                  hw(name='s1'), hw(name='s2'), hw(name='s3')])
   return task.interpolate()[0]
开发者ID:MustafaOrkunAcar,项目名称:incubator-aurora,代码行数:11,代码来源:test_failure_limit.py

示例5: flaky_task

def flaky_task():
  task = Task(
    name = "failing_task",
    max_failures = 2,
    processes = [
      Process(name = "a", max_failures=1, min_duration=1, cmdline="echo hello world"),
      Process(name = "b", max_failures=2, min_duration=1, cmdline="exit 1"),
      Process(name = "c", max_failures=1, min_duration=1, final=True, cmdline="echo hello world")
    ],
    constraints = [{'order': ['a', 'b']}]
  )
  return task.interpolate()[0]
开发者ID:betepahos,项目名称:incubator-aurora,代码行数:12,代码来源:test_angry.py

示例6: from_file

 def from_file(cls, filename, **kw):
   try:
     with safe_open(filename) as fp:
       task = Task.json_load(fp)
     return cls(task, **kw)
   except Exception:
     return None
开发者ID:KancerEzeroglu,项目名称:aurora,代码行数:7,代码来源:loader.py

示例7: from_file

 def from_file(filename, **kw):
   try:
     with safe_open(filename) as fp:
       task = Task.json_load(fp)
     return ThermosTaskWrapper(task, **kw)
   except Exception as e:
     return None
开发者ID:MustafaOrkunAcar,项目名称:incubator-aurora,代码行数:7,代码来源:loader.py

示例8: task

 def task(cls):
   ping_template = Process(
     name="{{process_name}}",
     min_duration=1,
     max_failures=5,
     cmdline = "echo {{process_name}} pinging;                                "
               "echo ping >> {{process_name}};                                "
               "echo current count $(cat {{process_name}} | wc -l);           "
               "if [ $(cat {{process_name}} | wc -l) -eq {{num_runs}} ]; then "
               "  exit 0;                                             "
               "else                                                  "
               "  exit 1;                                             "
               "fi                                                    ")
   tsk = Task(
     name = "pingping",
     resources = Resources(cpu = 1.0, ram = 16*1024*1024, disk = 16*1024),
     processes = [
       ping_template.bind(process_name = "p1", num_runs = 1),
       ping_template.bind(process_name = "p2", num_runs = 2),
       ping_template.bind(process_name = "p3", num_runs = 3),
     ]
   )
   return tsk.interpolate()[0]
开发者ID:betepahos,项目名称:incubator-aurora,代码行数:23,代码来源:test_failing_runner.py

示例9: task

 def task(cls):
   task = Task(name="task", processes=[Process(name="process", cmdline=SIMPLEFORK_SCRIPT)])
   return task.interpolate()[0]
开发者ID:bhuvan,项目名称:incubator-aurora,代码行数:3,代码来源:test_staged_kill.py


注:本文中的apache.thermos.config.schema.Task类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。