Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raw_text = input("Model prompt >>> ")
context_tokens = enc.encode(raw_text)
generated = 0
for _ in range(nsamples // batch_size):
out = sess.run(output, feed_dict={
context: [context_tokens for _ in range(batch_size)]
})[:, len(context_tokens):]
for i in range(batch_size):
generated += 1
text = enc.decode(out[i])
print("=" * 40 + " SAMPLE " + str(generated) + " " + "=" * 40)
print(text)
print("=" * 80)
if __name__ == '__main__':
fire.Fire(interact_model)
Args:
code: The status code that the FireExit should contain.
regexp: stdout must match this regex.
Yields:
Yields to the wrapped context.
"""
with self.assertOutputMatches(stderr=regexp):
with self.assertRaises(core.FireExit):
try:
yield
except core.FireExit as exc:
if exc.code != code:
raise AssertionError('Incorrect exit code: %r != %r' % (exc.code,
code))
self.assertIsInstance(exc.trace, trace.FireTrace)
raise
print('Fine-tuning only the last layer...')
learn.freeze_to(-1)
if use_regular_schedule:
print('Using regular schedule. Setting use_clr=None, n_cycles=cl, cycle_len=None.')
use_clr = None
n_cycles = cl
cl = None
else:
n_cycles = 1
learn.fit(lrs, n_cycles, wds=wd, cycle_len=cl, use_clr=(8,8) if use_clr else None)
print('Plotting lrs...')
learn.sched.plot_lr()
learn.save(final_clas_file)
if __name__ == '__main__': fire.Fire(train_clas)
Path(config.history_path).unlink()
elif cli_args:
getattr(chepy_cli, cli_method)(
fire_obj, **{cli_args.group(1): cli_args.group(2)}
)
else:
getattr(chepy_cli, cli_method)(fire_obj)
else:
for method in chepy:
if not method.startswith("_") and not isinstance(
getattr(Chepy, method), property
):
fire.decorators._SetMetadata(
getattr(Chepy, method),
fire.decorators.ACCEPTS_POSITIONAL_ARGS,
False,
)
args_data += prompt.split()
if args_data[-1] != "-":
args_data.append("-")
try:
last_command = prompt.split() + ["-"]
fire_obj = fire.Fire(Chepy, command=args_data)
# handle required args for methods
except fire.core.FireExit:
args_data = args_data[: -len(last_command)]
except TypeError as e:
print(red(e.message))
except SystemExit:
sys.exit()
except:
# Delete the cli history file
elif cli_method == "cli_delete_history":
Path(config.history_path).unlink()
elif cli_args:
getattr(chepy_cli, cli_method)(
fire_obj, **{cli_args.group(1): cli_args.group(2)}
)
else:
getattr(chepy_cli, cli_method)(fire_obj)
else:
for method in chepy:
if not method.startswith("_") and not isinstance(
getattr(Chepy, method), property
):
fire.decorators._SetMetadata(
getattr(Chepy, method),
fire.decorators.ACCEPTS_POSITIONAL_ARGS,
False,
)
args_data += prompt.split()
if args_data[-1] != "-":
args_data.append("-")
try:
last_command = prompt.split() + ["-"]
fire_obj = fire.Fire(Chepy, command=args_data)
# handle required args for methods
except fire.core.FireExit:
args_data = args_data[: -len(last_command)]
except TypeError as e:
print(red(e.message))
except SystemExit:
def _parse_args_kwargs(params):
from fire.parser import DefaultParseValue
args = ()
kwargs = {}
for param in _param_split(params):
if '=' not in param:
args += (DefaultParseValue(param),)
else:
k, v = param.split('=')
kwargs[k.strip()] = DefaultParseValue(v)
return args, kwargs
def _parse_args_kwargs(params):
from fire.parser import DefaultParseValue
args = ()
kwargs = {}
for param in _param_split(params):
if '=' not in param:
args += (DefaultParseValue(param),)
else:
k, v = param.split('=')
kwargs[k.strip()] = DefaultParseValue(v)
return args, kwargs
def connect_rvo2_with_smoke_query(self):
for floor in self.floors:
try:
floor.smoke_query = PartitionQuery(floor=floor.floor)
except Exception as e:
self.wlogger.error(e)
exit(1)
else:
self.wlogger.info('Smoke query connected to floor: {}'.format(floor.floor))
def main():
fire.Fire(CoARiJ)
out += 'Total {} K8s Cluster Role Bindings Enumerated\n'.format(data['payload']['cluster_role_bindings']['count'])
out += 'K8s recources saved under {}.\n'.format(module_info['data_saved'])
return out
def set_args():
args = {}
return args
if __name__ == "__main__":
print('Running module {}...'.format(module_info['name']))
args = fire.Fire(set_args)
data = main(args)
if data is not None:
summary = summary(data)
if len(summary) > 1000:
raise ValueError('The {} module\'s summary is too long ({} characters). Reduce it to 1000 characters or fewer.'.format(module_info['name'], len(summary)))
if not isinstance(summary, str):
raise TypeError(' The {} module\'s summary is {}-type instead of str. Make summary return a string.'.format(module_info['name'], type(summary)))
# print('RESULT:')
# print(json.dumps(data, indent=4, default=str))
print('{} completed.\n'.format(module_info['name']))
print('MODULE SUMMARY:\n\n{}\n'.format(summary.strip('\n')))