def main(argv) -> int: logging.addLevelName(logging.INFO+5, 'NOTICE') logging.basicConfig() log_level = os.environ.get('PYTHONLOGLEVEL', str(logging.INFO)) try: log_level = int(log_level) except ValueError: pass logging.root.setLevel(log_level) attributes = {'user': argv[1], 'url': argv[2]} if not attributes['url'].endswith('/'): attributes['url'] += '/' logger.info('Fetching tickets from WebDesk...') tickets = webdesk.get_tickets(attributes) tw = tasks.get_tw() logger.debug('Getting tickets from TaskWarrior...') tasks_ = tasks.get_tasks(tw) new_tasks = tickets.keys() - tasks_.keys() existing_tasks = tickets.keys() & tasks_.keys() missing_tasks = tasks_.keys() - tickets.keys() logger.info('%d new, %d existing and %d missing tasks', len(new_tasks), len(existing_tasks), len(missing_tasks)) for k in new_tasks: tasks.add_task(tw, tickets[k]['task']) for k in existing_tasks: tickets[k]['task']['webdesk_unhide'] = 1 tasks.update_task(tw, tickets[k]['task']) if missing_tasks: logger.info('Fetching missing tickets from WebDesk...') missing_tickets = webdesk.get_tickets(attributes, {k: v for k, v in tasks_.items() if k in missing_tasks}) for k, v in missing_tickets.items(): v['task']['webdesk_hidden'] = 1 tasks.update_task(tw, v['task']) if v['task']['webdesk_status'] == 'Closed': tasks.complete_task(tw, v['task']) return 0
def main(args): validate_args(args) loaders = get_dataloader(args.training.batch_size, **vars(args.dataset.options)) args.model.input_size = loaders['train'].dataset.input_size tasks = get_tasks(args.tasks.names, args.tasks.weights, loaders['train'].dataset) backbone, heads = build_dense(tasks, args.model) if not hasattr(args.rotograd, 'latent_size'): args.rotograd.latent_size = backbone.output_size method = args.algorithms.method if method == 'rotograd': model = RotoGrad(backbone, heads, args.rotograd.latent_size, normalize_losses=args.rotograd.normalize) elif method == 'rotate': model = RotateOnly(backbone, heads, args.rotograd.latent_size, normalize_losses=args.rotograd.normalize) else: model = VanillaMTL(backbone, heads) # TODO add normalize_losses print(model) model.to(args.device) optimizers, schedulers = get_optimizers(model, args) trainer, evaluator = create_trainer_and_evaluator(model, tasks, optimizers, loaders, args) decorate_trainer(trainer, args, model, schedulers) decorate_evaluator(evaluator, tasks, args) trainer.run(loaders['train'], max_epochs=args.training.epochs) print("Model metrics") evaluator.run(loaders['test'])
def receive_from_frontend_callback(ch, method, properties, body): ch.basic_ack(delivery_tag=method.delivery_tag) received_data = ts.decode_obj(body) print(" [x] Master received envelope from frontend") #get number of consumers availible queue_state = m_s_channel.queue_declare(queue=m_to_s_queue, durable=True) workers_num = int(queue_state.method.consumer_count) gjson = ts.str_to_json(received_data.map_str) task_arr = ts.get_tasks(received_data.parts_num, gjson) #calculate master's portion master_portion = len(task_arr) // (workers_num + 1) for i in range(master_portion, len(task_arr)): #SEND: master TO slave msg.send(m_s_channel, m_to_s_queue, ts.encode_obj(task_arr[i])) print(" [x] Master sent task to slave") #master does it's work splitted_maps.clear() for i in range(0, master_portion): splitted_maps.append(ts.json_to_str(cm.crop_map(task_arr[i]))) print(" [x] Master processed it's part of work") for i in range(master_portion, len(task_arr)): #RECEIVE: master FROM slave msg.receive(m_s_channel, s_to_m_queue, receive_from_slave_callback) print(" [x] Master received map from slave") #SEND: master TO frontend message = ts.str_list_to_one_str(splitted_maps) msg.send(f_m_channel, m_to_f_queue, message) print(" [x] Master sent maps to frontend")
def get_tasks(): """Route for get all tasks""" if request.args.get('keyword'): keyword = request.args.get('keyword') tasks_data = tasks.get_tasks_many(keyword) else: tasks_data = tasks.get_tasks() resp_data = [] if tasks_data: for task in tasks_data: # Get task attribute except 'id' and 'user_id' attributes = { k:v for k,v in task.iteritems() if k not in('id', 'user_id') } resp_data.append({ 'type': 'tasks', 'id': task['id'], 'attributes': attributes }) response = { 'links': { 'self': request.url }, 'data' : resp_data } resp = jsonify(response) # Header JSONAPI resp.mimetype = 'application/vnd.api+json' resp.status_code = 200 return resp
def __init__(self, activity): ''' Initialize the task list ''' Gtk.Alignment.__init__(self) self.activity = activity self.set_size_request(Gdk.Screen.width() - style.GRID_CELL_SIZE, -1) cssProvider = Gtk.CssProvider() cssProvider.load_from_path('style.css') screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.button_was_pressed = True self.current_task = None self.keyname = None self.task_button = None self.progress_checked = False self.completed = False self._name = None self._email = None self._graphics = None self._first_time = True self.yes_task = None self.no_task = None self._task_list = tasks.get_tasks(self) self._uid = None self.returning_user = False self._assign_required() name = self.read_task_data(NAME_UID) email_address = self.read_task_data(EMAIL_UID) phone_number = self.read_task_data(PHONE_NUMBER_UID) school = self.read_task_data(SCHOOL_NAME) if name is None or email_address is None or phone_number is None or \ school is None: self.current_task = 0 else: self.current_task = self.uid_to_task_number(CONFIRMATION_TASK) self.returning_user = True self._graphics_grid = Gtk.Grid() self._graphics_grid.set_row_spacing(style.DEFAULT_SPACING) self._graphics_grid.set_column_spacing(style.DEFAULT_SPACING) self.set(xalign=0.5, yalign=0, xscale=0, yscale=0) self.add(self._graphics_grid) self._graphics_grid.show() self.activity.load_graphics_area(self) self._task_button_alignment = Gtk.Alignment.new( xalign=0.5, yalign=0.5, xscale=0, yscale=0) self._task_button_alignment.set_size_request( Gdk.Screen.width() - style.GRID_CELL_SIZE, -1) grid = Gtk.Grid() grid.set_row_spacing(style.DEFAULT_SPACING) grid.set_column_spacing(style.DEFAULT_SPACING) grid.set_column_homogeneous(True) self._refresh_button = Gtk.Button(_('Refresh'), name='refresh-button') self._refresh_button.connect('clicked', self._refresh_button_cb) left = Gtk.Alignment.new(xalign=0, yalign=0.5, xscale=0, yscale=0) left.add(self._refresh_button) self._refresh_button.hide() grid.attach(left, 0, 0, 1, 1) left.show() mid = Gtk.Alignment.new(xalign=0.5, yalign=0.5, xscale=0, yscale=0) yes_next_no_grid = Gtk.Grid() yes_next_no_grid.set_row_spacing(style.DEFAULT_SPACING) yes_next_no_grid.set_column_spacing(style.DEFAULT_SPACING) yes_next_no_grid.set_column_homogeneous(True) self._yes_button = Gtk.Button(_('Yes'), name='next-button') self._yes_button.connect('clicked', self.jump_to_task_cb, 'yes') yes_next_no_grid.attach(self._yes_button, 0, 0, 1, 1) self._yes_button.hide() self.task_button = Gtk.Button(_('Next'), name='next-button') self.task_button.connect('clicked', self._task_button_cb) yes_next_no_grid.attach(self.task_button, 1, 0, 1, 1) self.task_button.show() self._no_button = Gtk.Button(_('No'), name='next-button') self._no_button.connect('clicked', self.jump_to_task_cb, 'no') yes_next_no_grid.attach(self._no_button, 2, 0, 1, 1) self._no_button.hide() mid.add(yes_next_no_grid) yes_next_no_grid.show() grid.attach(mid, 1, 0, 1, 1) mid.show() right_grid = Gtk.Grid() self._my_turn_button = Gtk.Button(_('My Turn'), name='my-turn-button') self._my_turn_button.connect('clicked', self._my_turn_button_cb) right_grid.attach(self._my_turn_button, 0, 0, 1, 1) self._my_turn_button.hide() self._skip_button = Gtk.Button(_('Skip this section'), name='my-turn-button') self._skip_button.connect('clicked', self._skip_button_cb) right_grid.attach(self._skip_button, 1, 0, 1, 1) self._skip_button.hide() right = Gtk.Alignment.new(xalign=1.0, yalign=0.5, xscale=0, yscale=0) right.add(right_grid) right_grid.show() grid.attach(right, 2, 0, 1, 1) right.show() self._task_button_alignment.add(grid) grid.show() self.activity.load_button_area(self._task_button_alignment) self._task_button_alignment.show() self._progress_bar = None self._progress_bar_alignment = Gtk.Alignment.new( xalign=0.5, yalign=0.5, xscale=0, yscale=0) self._progress_bar_alignment.set_size_request( Gdk.Screen.width() - style.GRID_CELL_SIZE, -1) self.activity.load_progress_area(self._progress_bar_alignment) self._progress_bar_alignment.show()
def index(): (result, ids) = tasks.get_tasks() return render_template('index.html', tasks=result, ids=ids)
def get_tasks(group_id): return tasks.get_tasks(group_id)
def get_tasks(): """GET kanban state""" print("getting...") return jsonify(tasks.get_tasks())
def save_cipher(): """Saves current state in cipher""" print("Ciphering...") data = tasks.get_tasks() cipher.write_to_file(data) return 'Success'