def test_add_id_2(self): schema_in = build_schema(''' type Human { id: ID! } ''') config = {'generation': {'field_for_id': True}} try: generator.run(schema_in, config) assert False except: assert True
def test_datetime_scalar_2(self): schema_in = build_schema(''' scalar DateTime type datetime_test { date: DateTime! } ''') config = {'generation': {'generate_datetime': True}} try: generator.run(schema_in, config) assert True except: assert False
def test_add_id_1(self): schema_in = build_schema(''' type Human ''') config = {'generation': {'field_for_id': True}} expected = build_schema(''' type Human { id: ID! } ''') schema_out = generator.run(schema_in, config) assert compare.is_equals_schema(schema_out, expected)
def test_add_lastUpdateDate_1(self): schema_in = build_schema(''' type Test ''') config = {'generation': {'field_for_last_update_date': True}} expected = build_schema(''' scalar DateTime type Test { _lastUpdateDate: DateTime } ''') schema_out = generator.run(schema_in, config) assert compare.is_equals_schema(schema_out, expected)
def creation(self, text_input): last_idx = int(sorted(glob.glob('static/results/*'))[-1].split('/')[-1]) idx = 1 + last_idx output_dir = 'static/results/%04d' % idx image_path = '{}/{}'.format(output_dir, 'image.jpg') config_path = '{}/{}'.format(output_dir, 'config.json') config = { 'text_inputs': [{ 'text': text_input, 'weight': 10.0 }], 'size': (512, 512), 'num_iterations': 1000, 'batch_size': 1, 'cutn': 24, 'weight_decay': 0.1, 'learning_rate': 0.1, 'lr_decay_after': 400, 'lr_decay_rate': 0.995 } if not os.path.isdir(output_dir): os.mkdir(output_dir) with open(config_path, 'w') as outfile: json.dump(config, outfile) def callback(results): #status = 'done' if results['iteration'] == results['num_iterations'] else 'generating' #status = '%s %d %d'%(status, results['iteration'], results['num_iterations']) output = { 'current': results['iteration'], 'total': results['num_iterations'] } self.update_state(state='PROGRESS', meta=output) img = generator.run(config, callback) img.save(image_path) results = { 'current': config['num_iterations'], 'total': config['num_iterations'], 'result': image_path } return results
def test_add_input_to_create_1(self): schema_in = build_schema(''' type Human { id: ID! name: String! } ''') config = {'generation': {'input_to_create_objects': True}} expected = build_schema(''' type Human { id: ID! name: String! } input _InputToCreateHuman { name: String! } ''') schema_out = generator.run(schema_in, config) assert compare.is_equals_schema(schema_out, expected)
#!/usr/bin/env python if __name__=='__main__': import generator import sys generator.run(sys.argv)
metavar='str', type=str, default='', help= 'put this string in the preamble of output file (default: \"%(default)s\")' ) parser.add_argument('--verbose', action='store_true', help='displays details about the process') args = parser.parse_args() with open(args.file, 'r') as file: stdout = sys.stdout if args.verbose else open(devnull, 'w') print('Read grammar ... ', file=stdout, end='', flush=True) cfg = CFG.fromsource(file, args.sep) print('ok', file=stdout) print('Generate derivation tree ... ', file=stdout, end='', flush=True) tree = run(cfg, args.depth, args.size) print('ok', file=stdout) print('Convert to string ... ', file=stdout, end='', flush=True) if args.preamble != '': preamble = open(args.preamble, 'r').read() + '\n' else: preamble = '' if args.output == 'stdout': print(preamble + tree.to_str(not args.dynamic)) else: with open(args.output, 'w') as output: output.write(preamble + tree.to_str()) print('ok', file=stdout)
def draw_menu(stdscr): response = True mode = "main" while response: if mode == "main": stdscr.clear() stdscr.addstr(0, 0, "=== SPOTIFY PLAYLIST GENERATOR ===") stdscr.addstr(1, 0, "===== MAIN MENU =====") stdscr.addstr(2, 2, "[q] = quit") stdscr.addstr(3, 2, "[g] = generate playlists") stdscr.addstr(4, 2, "[m] = manage categorization") # stdscr.addstr(5, 2, "[d] = display") msg = "Press a key to select an option:" if str(response) != "True": msg = response stdscr.addstr(7, 0, "> " + msg) c = stdscr.getch() response = process_menu_input(c) if response == "GENERATE_PLAYLIST": mode = "generate" response = True elif response == "MANAGE_CATEGORIES": mode = "manage" response = True elif response == "DISPLAY_DATA": mode = "display" response = True elif mode == "display": stdscr.clear() stdscr.addstr(0, 0, "=== SPOTIFY PLAYLIST GENERATOR ===") stdscr.addstr(1, 0, "===== DISPLAY DATA =====") stdscr.addstr(2, 2, "[q] = quit") stdscr.addstr(3, 2, "[t] = display tracks") stdscr.addstr(4, 2, "[a] = display analysis") stdscr.addstr(5, 2, "[d] = display definitions") msg = "Press a key to select an option:" if str(response) != "True": msg = response stdscr.addstr(7, 0, "> " + msg) c = stdscr.getch() response = process_display_input(c) if response == "DISPLAY_DATA_TRACKS": pass elif response == "DISPLAY_DATA_ANALYSIS": pass elif response == "DISPLAY_DATA_DEFINITIONS": pass elif mode == "generate": stdscr.clear() stop_curses() run() mode = "main" elif mode == "manage": stdscr.clear() stop_curses() manage() mode = "main" else: break
def generator_task(generator): print "New generator worker started..." generator.run() return
import generator as gner parameters = { 'ref_type': 'height', 'ref_h': 60, 'ref_w': 40, 'norm_len': 58, 'resize': 256, 'min_vail_len': 10, 'positive_up_boundary': 1.1, 'positive_low_boundary': 0.9, 'regression_up_boundary': 1.1, 'regression_low_boundary': 0.9, 'ignore_up_boundary': 2, 'ignore_low_boundary': 0.5, 'postive_gener_ratio': 0.1, 'regression_gener_ratio': 0.2, 'ignore_gener_ratio': 0.4, 'Image_path': '/mnt/hgfs/linux_share/phone_data/Image', 'Anno_path': '/mnt/hgfs/linux_share/phone_data/Anno_txt' } gner.run(parameters)
#!/usr/bin/env python if __name__ == '__main__': import generator import sys generator.run(sys.argv)