本文整理汇总了Python中tests.mockboto.to_iso8601函数的典型用法代码示例。如果您正苦于以下问题:Python to_iso8601函数的具体用法?Python to_iso8601怎么用?Python to_iso8601使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_iso8601函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_clock_skew
def test_clock_skew(self):
# make sure something reasonable happens if now is before
# the start time
jf = MockEmrObject(
creationdatetime=to_iso8601(datetime(2010, 6, 6, 4)),
startdatetime=to_iso8601(datetime(2010, 6, 6, 4, 26)))
self.assertEqual(
est_time_to_hour(jf, now=datetime(2010, 6, 6, 4, 25, 59)),
timedelta(seconds=1))
开发者ID:DanisHack,项目名称:mrjob,代码行数:10,代码来源:test_pool.py
示例2: test_started
def test_started(self):
jf = MockEmrObject(
creationdatetime=to_iso8601(datetime(2010, 6, 6, 4)),
startdatetime=to_iso8601(datetime(2010, 6, 6, 4, 26)))
self.assertEqual(
est_time_to_hour(jf, now=datetime(2010, 6, 6, 4, 35)),
timedelta(minutes=51))
self.assertEqual(
est_time_to_hour(jf, now=datetime(2010, 6, 6, 5, 20)),
timedelta(minutes=6))
self.assertEqual(
est_time_to_hour(jf, now=datetime(2010, 6, 6, 6, 26)),
timedelta(minutes=60))
开发者ID:DanisHack,项目名称:mrjob,代码行数:16,代码来源:test_pool.py
示例3: test_started
def test_started(self):
cs = MockEmrObject(
status=MockEmrObject(
timeline=MockEmrObject(
creationdatetime=to_iso8601(datetime(2010, 6, 6, 4, 26)),
readydatetime=to_iso8601(datetime(2010, 6, 6, 4, 30)))))
self.assertEqual(
_est_time_to_hour(cs, now=datetime(2010, 6, 6, 4, 35)),
timedelta(minutes=51))
self.assertEqual(
_est_time_to_hour(cs, now=datetime(2010, 6, 6, 5, 20)),
timedelta(minutes=6))
self.assertEqual(
_est_time_to_hour(cs, now=datetime(2010, 6, 6, 6, 26)),
timedelta(minutes=60))
开发者ID:Milkigit,项目名称:mrjob,代码行数:18,代码来源:test_pool.py
示例4: test_now_is_automatically_set
def test_now_is_automatically_set(self):
jf = MockEmrObject(
creationdatetime=to_iso8601(datetime.utcnow()))
t = est_time_to_hour(jf)
self.assertLessEqual(t, timedelta(minutes=60))
self.assertGreater(t, timedelta(minutes=59))
jf2 = MockEmrObject(
creationdatetime=to_iso8601(
datetime.utcnow() - timedelta(minutes=1)),
startdatetime=to_iso8601(datetime.utcnow()))
t = est_time_to_hour(jf2)
self.assertLessEqual(t, timedelta(minutes=60))
self.assertGreater(t, timedelta(minutes=59))
开发者ID:DanisHack,项目名称:mrjob,代码行数:18,代码来源:test_pool.py
示例5: step
def step(
jar="/home/hadoop/contrib/streaming/hadoop-streaming.jar",
args=["-mapper", "my_job.py --mapper", "-reducer", "my_job.py --reducer"],
state="COMPLETE",
create_hours_ago=None,
start_hours_ago=None,
end_hours_ago=None,
name="Streaming Step",
action_on_failure="TERMINATE_JOB_FLOW",
**kwargs
):
if create_hours_ago:
kwargs["creationdatetime"] = to_iso8601(self.now - timedelta(hours=create_hours_ago))
if start_hours_ago:
kwargs["startdatetime"] = to_iso8601(self.now - timedelta(hours=start_hours_ago))
if end_hours_ago:
kwargs["enddatetime"] = to_iso8601(self.now - timedelta(hours=end_hours_ago))
kwargs["args"] = [MockEmrObject(value=a) for a in args]
return MockEmrObject(jar=jar, state=state, name=name, action_on_failure=action_on_failure, **kwargs)
开发者ID:GabbleEngineer,项目名称:mrjob,代码行数:19,代码来源:test_terminate_idle_job_flows.py
示例6: step
def step(jar='/home/hadoop/contrib/streaming/hadoop-streaming.jar',
args=['-mapper', 'my_job.py --mapper',
'-reducer', 'my_job.py --reducer'],
state='COMPLETE',
start_time_back=None,
end_time_back=None,
name='Streaming Step',
action_on_failure='TERMINATE_JOB_FLOW',
**kwargs):
if start_time_back:
kwargs['startdatetime'] = to_iso8601(
self.now - timedelta(hours=start_time_back))
if end_time_back:
kwargs['enddatetime'] = to_iso8601(
self.now - timedelta(hours=end_time_back))
kwargs['args'] = [MockEmrObject(value=a) for a in args]
return MockEmrObject(
jar=jar, state=state, name=name,
action_on_failure=action_on_failure, **kwargs)
开发者ID:Jyrsa,项目名称:mrjob,代码行数:19,代码来源:terminate_idle_job_flows_test.py
示例7: test_now_is_automatically_set
def test_now_is_automatically_set(self):
cs = MockEmrObject(
status=MockEmrObject(
timeline=MockEmrObject(
creationdatetime=to_iso8601(datetime.utcnow()))))
t = _est_time_to_hour(cs)
self.assertLessEqual(t, timedelta(minutes=60))
self.assertGreater(t, timedelta(minutes=59))
开发者ID:Milkigit,项目名称:mrjob,代码行数:10,代码来源:test_pool.py
示例8: test_can_get_all_job_flows
def test_can_get_all_job_flows(self):
now = datetime.datetime.utcnow()
NUM_JOB_FLOWS = 2222
assert_gt(NUM_JOB_FLOWS, DEFAULT_MAX_JOB_FLOWS_RETURNED)
for i in range(NUM_JOB_FLOWS):
jfid = 'j-%04d' % i
self.mock_emr_job_flows[jfid] = MockEmrObject(
creationdatetime=to_iso8601(now - datetime.timedelta(minutes=i)),
jobflowid=jfid)
emr_conn = EMRJobRunner().make_emr_conn()
# ordinary describe_jobflows() hits the limit on number of job flows
some_jfs = emr_conn.describe_jobflows()
assert_equal(len(some_jfs), DEFAULT_MAX_JOB_FLOWS_RETURNED)
all_jfs = describe_all_job_flows(emr_conn)
assert_equal(len(all_jfs), NUM_JOB_FLOWS)
assert_equal(sorted(jf.jobflowid for jf in all_jfs),
[('j-%04d' % i) for i in range(NUM_JOB_FLOWS)])
开发者ID:boursier,项目名称:mrjob,代码行数:22,代码来源:emr_test.py
示例9: create_fake_job_flows
def create_fake_job_flows(self):
self.now = datetime.utcnow().replace(microsecond=0)
# Build a step object easily
# also make it respond to .args()
def step(
jar="/home/hadoop/contrib/streaming/hadoop-streaming.jar",
args=["-mapper", "my_job.py --mapper", "-reducer", "my_job.py --reducer"],
state="COMPLETE",
create_hours_ago=None,
start_hours_ago=None,
end_hours_ago=None,
name="Streaming Step",
action_on_failure="TERMINATE_JOB_FLOW",
**kwargs
):
if create_hours_ago:
kwargs["creationdatetime"] = to_iso8601(self.now - timedelta(hours=create_hours_ago))
if start_hours_ago:
kwargs["startdatetime"] = to_iso8601(self.now - timedelta(hours=start_hours_ago))
if end_hours_ago:
kwargs["enddatetime"] = to_iso8601(self.now - timedelta(hours=end_hours_ago))
kwargs["args"] = [MockEmrObject(value=a) for a in args]
return MockEmrObject(jar=jar, state=state, name=name, action_on_failure=action_on_failure, **kwargs)
# empty job
self.mock_emr_job_flows["j-EMPTY"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=10)), state="STARTING"
)
# job that's bootstrapping
self.mock_emr_job_flows["j-BOOTSTRAPPING"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
startdatetime=to_iso8601(self.now - timedelta(hours=9, minutes=55)),
state="BOOTSTRAPPING",
steps=[step(create_hours_ago=10, state="PENDING")],
)
# currently running job
self.mock_emr_job_flows["j-CURRENTLY_RUNNING"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=4, minutes=10)),
startdatetime=to_iso8601(self.now - timedelta(hours=4, minutes=15)),
state="RUNNING",
steps=[step(start_hours_ago=4, state="RUNNING")],
)
# finished job flow
self.mock_emr_job_flows["j-DONE"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
enddatetime=to_iso8601(self.now - timedelta(hours=5)),
readydatetime=to_iso8601(self.now - timedelta(hours=8)),
startdatetime=to_iso8601(self.now - timedelta(hours=9)),
state="COMPLETE",
steps=[step(start_hours_ago=8, end_hours_ago=6)],
)
# idle job flow
self.mock_emr_job_flows["j-DONE_AND_IDLE"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=5, minutes=5)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
state="WAITING",
steps=[step(start_hours_ago=4, end_hours_ago=2)],
)
# hive job flow (looks completed but isn't)
self.mock_emr_job_flows["j-HIVE"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=5, minutes=5)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
state="WAITING",
steps=[
step(
start_hours_ago=4,
end_hours_ago=4,
jar=("s3://us-east-1.elasticmapreduce/libs/script-runner/" "script-runner.jar"),
args=[],
)
],
)
# custom hadoop streaming jar
self.mock_emr_job_flows["j-CUSTOM_DONE_AND_IDLE"] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=5, minutes=5)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
state="WAITING",
steps=[
step(
start_hours_ago=4,
end_hours_ago=4,
jar=("s3://my_bucket/tmp/somejob/files/" "oddjob-0.0.3-SNAPSHOT-standalone.jar"),
args=[],
)
],
)
mock_conn = MockEmrConnection()
#.........这里部分代码省略.........
开发者ID:GabbleEngineer,项目名称:mrjob,代码行数:101,代码来源:test_terminate_idle_job_flows.py
示例10: create_fake_job_flows
def create_fake_job_flows(self):
self.now = datetime.utcnow().replace(microsecond=0)
# empty job
self.mock_emr_job_flows['j-EMPTY'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
steps=[],
)
# Build a step object easily
# also make it respond to .args()
def step(jar='/home/hadoop/contrib/streaming/hadoop-streaming.jar',
args=['-mapper', 'my_job.py --mapper',
'-reducer', 'my_job.py --reducer'],
state='COMPLETE',
start_time_back=None,
end_time_back=None,
name='Streaming Step',
action_on_failure='TERMINATE_JOB_FLOW',
**kwargs):
if start_time_back:
kwargs['startdatetime'] = to_iso8601(
self.now - timedelta(hours=start_time_back))
if end_time_back:
kwargs['enddatetime'] = to_iso8601(
self.now - timedelta(hours=end_time_back))
kwargs['args'] = [MockEmrObject(value=a) for a in args]
return MockEmrObject(
jar=jar, state=state, name=name,
action_on_failure=action_on_failure, **kwargs)
# currently running job
self.mock_emr_job_flows['j-CURRENTLY_RUNNING'] = MockEmrObject(
state='RUNNING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[step(start_time_back=4, state='RUNNING')],
)
# finished job flow
self.mock_emr_job_flows['j-DONE'] = MockEmrObject(
state='COMPLETE',
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
startdatetime=to_iso8601(self.now - timedelta(hours=9)),
enddatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[step(start_time_back=8, end_time_back=6)],
)
# idle job flow
self.mock_emr_job_flows['j-DONE_AND_IDLE'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[step(start_time_back=4, end_time_back=2)],
)
# hive job flow (looks completed but isn't)
self.mock_emr_job_flows['j-HIVE'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[step(
start_time_back=4,
end_time_back=4,
jar='s3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar',
args=[],
)],
)
# custom hadoop streaming jar
self.mock_emr_job_flows['j-CUSTOM_DONE_AND_IDLE'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[step(
start_time_back=4,
end_time_back=4,
jar='s3://my_bucket/tmp/somejob/files/oddjob-0.0.3-SNAPSHOT-standalone.jar',
args=[],
)],
)
mock_conn = MockEmrConnection()
# hadoop debugging without any other steps
jobflow_id = mock_conn.run_jobflow(name='j-DEBUG_ONLY',
log_uri='',
enable_debugging=True)
jf = mock_conn.describe_jobflow(jobflow_id)
self.mock_emr_job_flows['j-DEBUG_ONLY'] = jf
jf.state = 'WAITING'
jf.startdatetime=to_iso8601(self.now - timedelta(hours=2))
jf.steps[0].enddatetime=to_iso8601(self.now - timedelta(hours=2))
# hadoop debugging + actual job
# same jar as hive but with different args
jobflow_id = mock_conn.run_jobflow(name='j-HADOOP_DEBUGGING',
log_uri='',
enable_debugging=True,
#.........这里部分代码省略.........
开发者ID:Jyrsa,项目名称:mrjob,代码行数:101,代码来源:terminate_idle_job_flows_test.py
示例11: create_fake_job_flows
def create_fake_job_flows(self):
self.now = datetime.utcnow().replace(microsecond=0)
self.add_mock_s3_data({'my_bucket': {}})
# Build a step object easily
# also make it respond to .args()
def step(jar='/home/hadoop/contrib/streaming/hadoop-streaming.jar',
args=['-mapper', 'my_job.py --mapper',
'-reducer', 'my_job.py --reducer'],
state='COMPLETE',
create_hours_ago=None,
start_hours_ago=None,
end_hours_ago=None,
name='Streaming Step',
action_on_failure='TERMINATE_CLUSTER',
**kwargs):
if create_hours_ago:
kwargs['creationdatetime'] = to_iso8601(
self.now - timedelta(hours=create_hours_ago))
if start_hours_ago:
kwargs['startdatetime'] = to_iso8601(
self.now - timedelta(hours=start_hours_ago))
if end_hours_ago:
kwargs['enddatetime'] = to_iso8601(
self.now - timedelta(hours=end_hours_ago))
kwargs['args'] = [MockEmrObject(value=a) for a in args]
return MockEmrObject(
jar=jar, state=state, name=name,
action_on_failure=action_on_failure, **kwargs)
# empty job
self.mock_emr_job_flows['j-EMPTY'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
state='STARTING',
steps=[],
)
# job that's bootstrapping
self.mock_emr_job_flows['j-BOOTSTRAPPING'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
startdatetime=to_iso8601(
self.now - timedelta(hours=9, minutes=55)),
state='BOOTSTRAPPING',
steps=[step(create_hours_ago=10, state='PENDING')],
)
# currently running job
self.mock_emr_job_flows['j-CURRENTLY_RUNNING'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=4,
minutes=10)),
startdatetime=to_iso8601(self.now - timedelta(hours=4,
minutes=15)),
state='RUNNING',
steps=[step(start_hours_ago=4, state='RUNNING')],
)
# finished job flow
self.mock_emr_job_flows['j-DONE'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
enddatetime=to_iso8601(self.now - timedelta(hours=5)),
readydatetime=to_iso8601(self.now - timedelta(hours=8)),
startdatetime=to_iso8601(self.now - timedelta(hours=9)),
state='COMPLETE',
steps=[step(start_hours_ago=8, end_hours_ago=6)],
)
# idle job flow
self.mock_emr_job_flows['j-DONE_AND_IDLE'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=5, minutes=5)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
state='WAITING',
steps=[step(start_hours_ago=4, end_hours_ago=2)],
)
# idle job flow with an active lock
self.mock_emr_job_flows['j-IDLE_AND_LOCKED'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=5, minutes=5)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
state='WAITING',
steps=[step(start_hours_ago=4, end_hours_ago=2)],
)
self.add_mock_s3_data({
'my_bucket': {
'locks/j-IDLE_AND_LOCKED/2': b'not_you',
},
}, time_modified=datetime.utcnow())
# idle job flow with an expired lock
self.mock_emr_job_flows['j-IDLE_AND_EXPIRED'] = MockEmrObject(
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
readydatetime=to_iso8601(self.now - timedelta(hours=5, minutes=5)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
state='WAITING',
steps=[step(start_hours_ago=4, end_hours_ago=2)],
)
self.add_mock_s3_data({
'my_bucket': {
#.........这里部分代码省略.........
开发者ID:DanisHack,项目名称:mrjob,代码行数:101,代码来源:test_terminate_idle_job_flows.py
示例12: ago
def ago(**kwargs):
if any(v is None for v in kwargs.values()):
return None
return to_iso8601(self.now - timedelta(**kwargs))
开发者ID:kartheek6,项目名称:mrjob,代码行数:4,代码来源:test_terminate_idle_job_flows.py
示例13: create_fake_job_flows
def create_fake_job_flows(self):
self.now = datetime.utcnow().replace(microsecond=0)
# empty job
self.mock_emr_job_flows['j-EMPTY'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
steps=[],
)
# currently running job
self.mock_emr_job_flows['j-CURRENTLY_RUNNING'] = MockEmrObject(
state='RUNNING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=4)),
jar='/home/hadoop/contrib/streaming/hadoop-0.20-streaming.jar',
state='RUNNING',
)],
)
# finished job flow
self.mock_emr_job_flows['j-DONE'] = MockEmrObject(
state='COMPLETE',
creationdatetime=to_iso8601(self.now - timedelta(hours=10)),
startdatetime=to_iso8601(self.now - timedelta(hours=9)),
enddatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=8)),
enddatetime=to_iso8601(self.now - timedelta(hours=6)),
jar='/home/hadoop/contrib/streaming/hadoop-0.20-streaming.jar',
state='COMPLETE',
)],
)
# idle job flow
self.mock_emr_job_flows['j-DONE_AND_IDLE'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=4)),
enddatetime=to_iso8601(self.now - timedelta(hours=2)),
jar='/home/hadoop/contrib/streaming/hadoop-0.20-streaming.jar',
state='COMPLETE',
)],
)
# hive job flow (looks completed but isn't)
self.mock_emr_job_flows['j-HIVE'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=4)),
enddatetime=to_iso8601(self.now - timedelta(hours=4)),
jar='s3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar',
state='COMPLETE',
)],
)
# hadoop debugging + actual job
# hadoop debugging looks the same to us as Hive (they use the same
# jar). The difference is that there's also a streaming step.
self.mock_emr_job_flows['j-HADOOP_DEBUGGING'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[
MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
enddatetime=to_iso8601(self.now - timedelta(hours=5)),
jar='s3://us-east-1.elasticmapreduce/libs/script-runner/script-runner.jar',
state='COMPLETE',
),
MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=4)),
enddatetime=to_iso8601(self.now - timedelta(hours=2)),
jar='/home/hadoop/contrib/streaming/hadoop-0.20-streaming.jar',
state='COMPLETE',
)
],
)
# skip cancelled steps
self.mock_emr_job_flows['j-IDLE_AND_FAILED'] = MockEmrObject(
state='WAITING',
creationdatetime=to_iso8601(self.now - timedelta(hours=6)),
startdatetime=to_iso8601(self.now - timedelta(hours=5)),
steps=[
MockEmrObject(
startdatetime=to_iso8601(self.now - timedelta(hours=4)),
enddatetime=to_iso8601(self.now - timedelta(hours=3)),
jar='/home/hadoop/contrib/streaming/hadoop-0.20-streaming.jar',
state='FAILED',
),
MockEmrObject(
jar='/home/hadoop/contrib/streaming/hadoop-0.20-streaming.jar',
#.........这里部分代码省略.........
开发者ID:pjob,项目名称:mrjob,代码行数:101,代码来源:terminate_idle_job_flows_test.py
注:本文中的tests.mockboto.to_iso8601函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论