Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'struct %s {' % mangle_type(t, cx),
Block(['ptr_t pointer;',
'uint32_t region;']),
'};'])
return Value(
t,
Expr(mangle_type(t, cx), struct_definition),
types.Kind(t))
assert False
if types.is_struct_instance(t):
return None
if types.is_struct(t):
# For types defined in foreign modules, define nothing and return
# the foreign type.
if types.contains_key(cx.foreign_types, t):
t = types.find_key(cx.foreign_types, t)
return Value(t, Expr(t.name, []), types.Kind(t))
struct_definition = (
['// type def for %s' % t.pretty(),
'struct %s {' % mangle_type(t, cx),
Block(['%s %s;' % (trans_type(region, cx), region.name)
for region in t.regions] +
['%s %s;' % (trans_type(field_type, cx), field_name)
for field_name, field_type in t.field_map.iteritems()]),
'};'])
return Value(
t,
Expr(mangle_type(t, cx), struct_definition),
types.Kind(t))
return None
['// type def for multi-region pointers',
'struct %s {' % mangle_type(t, cx),
Block(['ptr_t pointer;',
'uint32_t region;']),
'};'])
return Value(
t,
Expr(mangle_type(t, cx), struct_definition),
types.Kind(t))
assert False
if types.is_struct_instance(t):
return None
if types.is_struct(t):
# For types defined in foreign modules, define nothing and return
# the foreign type.
if types.contains_key(cx.foreign_types, t):
t = types.find_key(cx.foreign_types, t)
return Value(t, Expr(t.name, []), types.Kind(t))
struct_definition = (
['// type def for %s' % t.pretty(),
'struct %s {' % mangle_type(t, cx),
Block(['%s %s;' % (trans_type(region, cx), region.name)
for region in t.regions] +
['%s %s;' % (trans_type(field_type, cx), field_name)
for field_name, field_type in t.field_map.iteritems()]),
'};'])
return Value(
t,
Expr(mangle_type(t, cx), struct_definition),
types.Kind(t))
return None
# council_room,
# cutpurse,
# embargo, /* choice1 = supply# */
# feast, /* choice1 is supply # of card gained) */
# gardens,
# great_hall,
# mine, /* choice1 is hand# of money to trash, choice2 is supply# of
MAX_PLAYERS = 4
cards = {}
cards[CardName.curse] = Card(CardName.curse,Card.defaultAction,1,0)
cards[CardName.estate] = Card(CardName.estate,Card.defaultAction,0,2)
cards[CardName.duchy] = Card(CardName.duchy,Card.defaultAction,0,5)
cards[CardName.province] = Card(CardName.province,Card.defaultAction,0,8)
cards[CardName.copper] = Card(CardName.copper,Card.copper,1,0)
cards[CardName.silver] = Card(CardName.silver,Card.silver,1,3)
cards[CardName.gold] = Card(CardName.gold,Card.gold,1,6)
cards[CardName.adventurer] = Card(CardName.adventurer,Card.adventurer,2,6)
cards[CardName.ambassador] = Card(CardName.ambassador,Card.ambassador,9,3)
cards[CardName.baron] = Card(CardName.baron,Card.baron,9,4)
cards[CardName.council_room] = Card(CardName.council_room,Card.council_room,2,5)
cards[CardName.cutpurse] = Card(CardName.cutpurse,Card.cutpurse,9,4)
cards[CardName.embargo] = Card(CardName.embargo,Card.embargo,9,2)
cards[CardName.feast] = Card(CardName.feast,Card.feast,2,4)
cards[CardName.gardens] = Card(CardName.gardens,Card.defaultAction,9,4)
cards[CardName.great_hall] = Card(CardName.great_hall,Card.great_hall,9,3)
cards[CardName.mine] = Card(CardName.mine,Card.mine,2,5)
cards[CardName.minion] = Card(CardName.minion,Card.defaultAction,9,9)
cards[CardName.outpost] = Card(CardName.outpost,Card.defaultAction,9,9)
cards[CardName.remodel] = Card(CardName.remodel,Card.defaultAction,2,4)
cards[CardName.salvager] = Card(CardName.salvager,Card.defaultAction,9,9)
# embargo, /* choice1 = supply# */
# feast, /* choice1 is supply # of card gained) */
# gardens,
# great_hall,
# mine, /* choice1 is hand# of money to trash, choice2 is supply# of
MAX_PLAYERS = 4
cards = {}
cards[CardName.curse] = Card(CardName.curse,Card.defaultAction,1,0)
cards[CardName.estate] = Card(CardName.estate,Card.defaultAction,0,2)
cards[CardName.duchy] = Card(CardName.duchy,Card.defaultAction,0,5)
cards[CardName.province] = Card(CardName.province,Card.defaultAction,0,8)
cards[CardName.copper] = Card(CardName.copper,Card.copper,1,0)
cards[CardName.silver] = Card(CardName.silver,Card.silver,1,3)
cards[CardName.gold] = Card(CardName.gold,Card.gold,1,6)
cards[CardName.adventurer] = Card(CardName.adventurer,Card.adventurer,2,6)
cards[CardName.ambassador] = Card(CardName.ambassador,Card.ambassador,9,3)
cards[CardName.baron] = Card(CardName.baron,Card.baron,9,4)
cards[CardName.council_room] = Card(CardName.council_room,Card.council_room,2,5)
cards[CardName.cutpurse] = Card(CardName.cutpurse,Card.cutpurse,9,4)
cards[CardName.embargo] = Card(CardName.embargo,Card.embargo,9,2)
cards[CardName.feast] = Card(CardName.feast,Card.feast,2,4)
cards[CardName.gardens] = Card(CardName.gardens,Card.defaultAction,9,4)
cards[CardName.great_hall] = Card(CardName.great_hall,Card.great_hall,9,3)
cards[CardName.mine] = Card(CardName.mine,Card.mine,2,5)
cards[CardName.minion] = Card(CardName.minion,Card.defaultAction,9,9)
cards[CardName.outpost] = Card(CardName.outpost,Card.defaultAction,9,9)
cards[CardName.remodel] = Card(CardName.remodel,Card.defaultAction,2,4)
cards[CardName.salvager] = Card(CardName.salvager,Card.defaultAction,9,9)
cards[CardName.sea_hag] = Card(CardName.sea_hag,Card.defaultAction,9,9)
cards[CardName.smithy] = Card(CardName.smithy,Card.defaultAction,2,4)
@deprecated.sphinx.deprecated
def foo3(self):
pass
@deprecated(version='0.1.32', reason='The %%docker magic is deprecated. Use `kfp.containers.build_image_from_working_dir` instead.')
def docker(line, cell):
"""cell magic for %%docker"""
if len(line.split()) < 2:
raise ValueError("usage: %%docker [gcr.io/project/image:tag] [gs://staging-bucket] [600] [kubeflow]\n\
arg1(required): target image tag\n\
arg2(required): staging gcs bucket\n\
arg3(optional): timeout in seconds, default(600)\n\
arg4(optional): namespace, default(kubeflow)")
if not cell.strip():
raise ValueError("Please fill in a dockerfile content in the cell.")
fields = line.split()
with tempfile.NamedTemporaryFile(mode='wt', delete=False) as f:
f.write(cell)
# submit the jobs
if self.run_local:
# this only works in python 3 ?!
with futures.ProcessPoolExecutor(n_jobs) as tp:
tasks = [tp.submit(self._submit_job, job_id, assignment_path, n_threads)
for job_id in range(n_jobs)]
[t.result() for t in tasks]
# for job_id in range(n_jobs):
# self._submit_job(job_id, assignment_path, n_threads)
else:
for job_id in range(n_jobs):
self._submit_job(job_id, assignment_path, n_threads)
# wait till all jobs are finished
if not self.run_local:
util.wait_for_jobs('papec')
# check the job outputs
processed_blocks, times = self._collect_outputs(n_jobs)
assert len(processed_blocks) == len(times)
success = len(processed_blocks) == n_blocks
# write output file if we succeed, otherwise write partial
# success to different file and raise exception
if success:
out = self.output()
# TODO does 'out' support with block?
fres = out.open('w')
json.dump({'times': times}, fres)
fres.close()
else:
log_path = os.path.join(self.tmp_folder, 'write_assignments_partial.json')
self._prepare_jobs(n_jobs, n_blocks, block_shape)
# submit the jobs
if self.run_local:
# this only works in python 3 ?!
with futures.ProcessPoolExecutor(n_jobs) as tp:
tasks = [tp.submit(self._submit_job, job_id)
for job_id in range(n_jobs)]
[t.result() for t in tasks]
else:
for job_id in range(n_jobs):
self._submit_job(job_id)
# wait till all jobs are finished
if not self.run_local:
util.wait_for_jobs('papec')
# check the job outputs
processed_jobs, times = self._collect_outputs(n_jobs)
assert len(processed_jobs) == len(times)
success = len(processed_jobs) == n_jobs
# write output file if we succeed, otherwise write partial
# success to different file and raise exception
if success:
out = self.output()
# TODO does 'out' support with block?
fres = out.open('w')
json.dump({'times': times}, fres)
fres.close()
else:
log_path = os.path.join(self.tmp_folder, 'find_uniques_partial.json')
self._prepare_jobs(n_jobs, n_blocks, config)
# submit the jobs
if self.run_local:
# this only works in python 3 ?!
with futures.ProcessPoolExecutor(n_jobs) as tp:
tasks = [tp.submit(self._submit_job, job_id)
for job_id in range(n_jobs)]
[t.result() for t in tasks]
else:
for job_id in range(n_jobs):
self._submit_job(job_id)
# wait till all jobs are finished
if not self.run_local:
util.wait_for_jobs('papec')
# check the job outputs
processed_blocks, n_components, times = self._collect_outputs(n_blocks)
assert len(processed_blocks) == len(n_components) == len(times)
success = len(processed_blocks) == n_blocks
# write output file if we succeed, otherwise write partial
# success to different file and raise exception
if success:
out = self.output()
# TODO does 'out' support with block?
fres = out.open('w')
json.dump({'n_components': n_components,
'times': times}, fres)
fres.close()
else:
def _submit_jobs(self, n_jobs, prefix):
from .. import util
if self.run_local:
# this only works in python 3 ?!
with futures.ProcessPoolExecutor(n_jobs) as tp:
tasks = [tp.submit(self._submit_job, job_id, prefix)
for job_id in range(n_jobs)]
[t.result() for t in tasks]
else:
for job_id in range(n_jobs):
self._submit_job(job_id, prefix)
# wait till all jobs are finished
if not self.run_local:
util.wait_for_jobs('papec')