def _clear_assignments_info(self) -> None: """clears any widgets in the frame and adds in the no assignments message""" utils.clear_frame(self._assignments_frame) utils.create_label(self._assignments_frame, 'You currently have no assignments.', 0, 0, colspan=self.A_COLSPAN)
def bazel_build_step(platform, project_name, http_config=None, file_config=None, build_only=False, test_only=False): host_platform = PLATFORMS[platform].get("host-platform", platform) pipeline_command = python_binary(host_platform) + " bazelci.py runner" if build_only: pipeline_command += " --build_only" if "host-platform" not in PLATFORMS[platform]: pipeline_command += " --save_but" if test_only: pipeline_command += " --test_only" if http_config: pipeline_command += " --http_config=" + http_config if file_config: pipeline_command += " --file_config=" + file_config pipeline_command += " --platform=" + platform return create_step( label=create_label(platform, project_name, build_only, test_only), commands=[fetch_bazelcipy_command(), pipeline_command], platform=platform, )
def runner_step( platform, project_name=None, http_config=None, file_config=None, git_repository=None, git_commit=None, monitor_flaky_tests=False, use_but=False, incompatible_flags=None, ): host_platform = PLATFORMS[platform].get("host-platform", platform) command = python_binary( host_platform) + " bazelci.py runner --platform=" + platform if http_config: command += " --http_config=" + http_config if file_config: command += " --file_config=" + file_config if git_repository: command += " --git_repository=" + git_repository if git_commit: command += " --git_commit=" + git_commit if monitor_flaky_tests: command += " --monitor_flaky_tests" if use_but: command += " --use_but" for flag in incompatible_flags or []: command += " --incompatible_flag=" + flag label = create_label(platform, project_name) return create_step(label=label, commands=[fetch_bazelcipy_command(), command], platform=platform)
def __init__(self, c: 'Course', course_widget: 'Course Widget', root_tracker: root_tracker.Root_Tracker): self._c = c self._course_widget = course_widget self._root_tracker = root_tracker self._root = tk.Tk() self._root.minsize(300, 300) utils.init_root_options(self._root) self._root.protocol('WM_DELETE_WINDOW', self.destroy) self._root_tracker.add_root(self._root) utils.init_theme() utils.configure_frame(self._root, colspan=self.COLSPAN) for i in range(5): self._root.rowconfigure(i + 2, weight=1) self._use_points = tk.IntVar(self._root) ttk.Checkbutton(self._root, text='Not Yet Graded', variable=self._use_points, command=self._disable_points_entry).grid(row=4) self._cat_name = utils.create_label(self._root, 'Category: ', 6, 0) self._cat = tk.StringVar(self._root) utils.create_option_menu(self._root, self._cat, [cat for cat in self._c.categories], 6, 1) self._points_entry = None
def _update_tkassignment(self, a: assignment.Assignemnt, row=None) -> None: """adds an assignment to the given course and updates the status bar""" if len( self._c.assignments ) - 1 < 1: # -1 because the new assignment has already been added to the list self._init_assignments_info() if row is None: row = len(self._c.assignments) s = ttk.Style() s.configure('TMenubutton', font=utils.FONT) menu = ttk.Menubutton(self._assignments_frame, text=a.name, style='TMenubutton') dropdown = tk.Menu(menu, tearoff=False) dropdown.add_command(label='Edit Assignment', command=lambda: self._edit_assingment(a)) dropdown.add_command(label='Remove Assignment', command=lambda: self._remove_assignment(a)) menu['menu'] = dropdown menu.grid(row=row, column=0, sticky=tk.EW, padx=10) cat = utils.create_label(self._assignments_frame, a.category, row, 1) if a.points is None: points = utils.create_label(self._assignments_frame, 'N/A', row, 2) else: points = utils.create_label(self._assignments_frame, a.points, row, 2) points_total = utils.create_label(self._assignments_frame, a.points_total, row, 3) self._assignments_widgets.update({ a: { 'name': menu, 'cat': cat, 'points': points, 'points_total': points_total } }) self._scroll.update_canvas()
def download_bazel_binary(dest_dir, platform): host_platform = PLATFORMS[platform].get("host-platform", platform) binary_path = "bazel-bin/src/bazel" if platform == "windows": binary_path = r"bazel-bin\src\bazel" source_step = create_label(host_platform, "Bazel", build_only=True) execute_command([ "buildkite-agent", "artifact", "download", binary_path, dest_dir, "--step", source_step ]) bazel_binary_path = os.path.join(dest_dir, binary_path) st = os.stat(bazel_binary_path) os.chmod(bazel_binary_path, st.st_mode | stat.S_IEXEC) return bazel_binary_path
def __getitem__(self, index): index = self.idxRef[self.split][index] im = self._loadImage(index) pts, c, s = self._getPartInfo(index) r = 0 if self.split == 'train': # scale and rotation s = s * np.clip(randn() * self.scale_factor + 1, 1 - self.scale_factor, 1 + self.scale_factor) r = np.clip(randn() * self.rot_factor, -self.rot_factor, self.rot_factor) if rand() <= 0.6 else 0 # Flip LR if rand() < 0.5: im = im[:, ::-1, :] pts = utils.fliplr_coords(pts, width=im.shape[1], matchedParts=self.flipRef) c[0] = im.shape[1] - c[0] # flip center point also # Color jitter im = np.clip(im * np.random.uniform(0.6, 1.4, size=3), 0, 1) # Prepare image im = utils.crop(im, c, s, r, self.inp_res) if im.ndim == 2: im = np.tile(im[..., np.newaxis], [1, 1, 3]) # small size image im_s = sktf.resize(im, [self.out_res, self.out_res], preserve_range=True) # (h, w, c) to (c, h, w) im = np.transpose(im, [2, 0, 1]) im_s = np.transpose(im_s, [2, 0, 1]) # Prepare label labels = np.zeros((self.nJoints, self.out_res, self.out_res)) new_pts = utils.transform(pts.T, c, s, r, self.out_res).T for i in range(self.nJoints): if pts[i, 0] > 0: labels[i] = utils.create_label(labels.shape[1:], new_pts[i], self.sigma) if not self.return_meta: return im.astype(np.float32), labels.astype( np.float32), im_s.astype(np.float32) else: meta = [pts, c, s, r] return im.astype(np.float32), labels.astype( np.float32), im_s.astype(np.float32), meta
def train(data_dir, train_imdb): center_crop_size = config.instance_size - config.stride random_crop_size = config.instance_size - 2 * config.stride train_z_transforms = transforms.Compose([ RandomStretch(), CenterCrop((config.examplar_size, config.examplar_size)), ToTensor() ]) train_x_transforms = transforms.Compose([ RandomStretch(), CenterCrop((center_crop_size, center_crop_size)), RandomCrop((random_crop_size, random_crop_size)), ToTensor() ]) train_dataset = RASNet_VIDDataset(train_imdb, data_dir, config, train_z_transforms, train_x_transforms) # create dataloader train_loader = DataLoader(train_dataset, batch_size=config.batch_size, shuffle=True, num_workers=config.train_num_workers, drop_last=True) net = RASNet() net.cuda() optimizer = torch.optim.SGD(net.parameters(), config.lr, config.momentum, config.weight_decay) scheduler = StepLR(optimizer, config.step_size, config.gamma) for i in range(config.num_epoch): scheduler.step() net.train() train_loss = [] for j, data in enumerate(train_loader): exemplar_imgs, instance_imgs, penalty = data exemplar_imgs = exemplar_imgs.cuda() instance_imgs = instance_imgs.cuda() output = net.forward(Variable(exemplar_imgs), Variable(instance_imgs)) train_response_flag = True response_size = output.shape[ 2:4] # 灵活使用,根据最终输出得到response map的大小,构造label的大小。 train_eltwise_label, train_instance_weight = create_label( response_size, config, use_gpu) loss = net.weight_loss(output, train_eltwise_label, train_instance_weight, penalty) loss.backward() optimizer.step() loss_train = loss.to('cpu').squeeze().data.numpy() train_loss.append(loss_train) # 保存模型 if not os.path.exists(config.model_save_path): os.makedirs(config.model_save_path) torch.save( net.state_dict(), config.model_save_path + "SiamFC_dict_" + str(i + 1) + "_model.pth") print("Epoch %d training loss: %f" % (i + 1, np.mean(train_loss)))
JiraComment( comment.author.name, comment.body, comment.created)) # if len(issue.fields.components) == 0: # if len(issue.fields.components) > 0 and issue.fields.components[0].name == 'Backend': # print issue.fields.components print jira_issue github_labels = [] label = convert(jira_issue.issue_type, JiraAttr.TYPE, GithubAttr.LABEL) if label is not None: github_labels.append(create_label(label, github_repo)) label = convert(jira_issue.status, JiraAttr.STATUS, GithubAttr.LABEL) if label is not None: github_labels.append(create_label(label, github_repo)) github_issue = github_repo.create_issue( jira_issue.summary, body=gen_body(jira_issue), assignee=convert(jira_issue.assignee, JiraAttr.USER, GithubAttr.LOGIN), labels=github_labels) github_issue.edit(state=convert(jira_issue.status, JiraAttr.STATUS, GithubAttr.STATE)) print github_issue
def __init__(self, root, root_frame, schedule: Schedule, start_page): # initialize the root frame self._root = root self._root.protocol('WM_DELETE_WINDOW', self._destroy) self._root_frame = root_frame self._schedule = schedule self._start_page = start_page self._mode = 0 # initialize the new menu bar if utils.SCHEDULE_MENU is None: self._menu = tk.Menu(self._root) file_menu = tk.Menu(self._menu, tearoff=0) file_menu.add_command(label='New Schedule', accelerator='Ctrl+N', command=self._new_schedule) file_menu.add_command(label='Open Schedule', accelerator='Ctrl+O', command=self._open_schedule) file_menu.add_command(label='Open Most Recent', accelerator='Ctrl+R', command=self._open_recent) file_menu.add_command(label='Save Schedule', accelerator='Ctrl+S', command=self._save) file_menu.add_command(label='Quit', accelerator='Ctrl+Q', command=self._quit) self._menu.add_cascade(label='File', menu=file_menu) edit_menu = tk.Menu(self._menu, tearoff=0) edit_menu.add_command(label='Edit Schedule', accelerator='Ctrl+E', command=self._edit) self._menu.add_cascade(label='Edit', menu=edit_menu) mode_menu = tk.Menu(self._menu, tearoff=0) mode_menu.add_command(label='Normal', command=lambda: self._switch_mode(0)) mode_menu.add_command(label='Experimental', command=lambda: self._switch_mode(1)) mode_menu.add_command( label='What is Mode?', command=lambda: tkmsg.showinfo( 'Help', 'Changing modes allows you to easily calculate grades without permanently making changes to your schedule.\n\nIn Normal Mode any changes you make will be saved when saving the schedule.\n\nIn Experimental Mode any changes you make will be discarded when saving or when switching back to Normal Mode.' )) self._menu.add_cascade(label='Mode', menu=mode_menu) utils.SCHEDULE_MENU = self._menu utils.set_menu(self._root, utils.SCHEDULE_MENU) # bind accelerators (same options as menu bar) self._root.bind('<Control-n>', self._new_schedule) self._root.bind('<Control-o>', self._open_schedule) self._root.bind('<Control-r>', self._open_recent) self._root.bind('<Control-q>', self._quit) self._root.bind('<Control-s>', self._save) self._root.bind('<Control-e>', self._edit) # initialize status bar (top) self._frame = tk.Frame(self._root_frame) self._frame.grid(row=0, column=0, sticky=tk.NSEW) self._frame.rowconfigure(2, weight=1) utils.configure_frame(self._frame, colspan=4) self._status_color = 'dark grey' self._status_frame = tk.Frame(self._frame, bg=self._status_color) self._status_frame.grid(row=0, column=0, columnspan=4, sticky=tk.NSEW) utils.configure_frame(self._status_frame, colspan=6) self._project_name = tk.Label(self._status_frame, bg=self._status_color, text=self._schedule.name) self._project_name.grid() self._total_units = tk.Label( self._status_frame, bg=self._status_color, text=f'Total Units Completed: {self._schedule.units}') self._total_units.grid(row=0, column=1) self._enrolled_units = tk.Label( self._status_frame, bg=self._status_color, text= f'Units Enrolled In: {sum([c.units for c in self._schedule.courses])}' ) self._enrolled_units.grid(row=0, column=2) self._total_courses = tk.Label( self._status_frame, bg=self._status_color, text=f'Total Courses: {len(self._schedule)}') self._total_courses.grid(row=0, column=3) self._gpa = tk.Label(self._status_frame, bg=self._status_color, text=f'GPA: {round(self._schedule.gpa, 2)}') self._gpa.grid(row=0, column=4) self._gpa_projected = tk.Label( self._status_frame, bg=self._status_color, text=f'Projected GPA: {round(self._schedule.projected_gpa, 2)}') self._gpa_projected.grid(row=0, column=5) # initialize course labels self._info_color = 'light grey' self._info_frame = tk.Frame(self._frame, padx=16, bg=self._status_color) self._info_frame.grid(row=1, column=0, columnspan=4, sticky=tk.NSEW) for i in range(4): self._info_frame.columnconfigure(i, weight=1, uniform='info') tk.Label(self._info_frame, text='{:^25}'.format('Course'), bg=self._info_color, bd=1, relief=tk.SUNKEN, padx=8, pady=5).grid(row=3, column=0, sticky=tk.EW) tk.Label(self._info_frame, text='{:^25}'.format('Units'), bg=self._info_color, bd=1, relief=tk.SUNKEN, padx=8, pady=5).grid(row=3, column=1, sticky=tk.EW) tk.Label(self._info_frame, text='{:^25}'.format('Total Assignments'), bg=self._info_color, bd=1, relief=tk.SUNKEN, padx=8, pady=5).grid(row=3, column=2, sticky=tk.EW) tk.Label(self._info_frame, text='{:^25}'.format('Grade'), bg=self._info_color, bd=1, relief=tk.SUNKEN, padx=8, pady=5).grid(row=3, column=3, sticky=tk.EW) # initialize courses frame self._course_scroll = ScrollingFrame(self._frame, 2, 1, 4, height_border=91, w_cutoff=30, h_cuttoff=30, scroll_size=15) self._courses_frame = self._course_scroll.frame utils.configure_frame(self._courses_frame, colspan=1) # other ttk.Button(self._frame, text='Add Course', command=self._create_tkcourse).grid(row=3, column=0, columnspan=4, sticky=tk.NSEW, padx=5, pady=0) bottom_bar = tk.Frame(self._frame) bottom_bar.grid(row=4, column=1, sticky=tk.NSEW) self._mode_label = utils.create_label(bottom_bar, 'Mode: Normal', padx=0, pady=0) self._root_tracker = root_tracker.Root_Tracker() self._root_tracker.add_root(self._root) self._total_rows = 0 self._init_courses() self._temp_file = None self.load_tkschedule()
def __init__(self, c: course.Course, schedule_frame: tk.Frame, scroll: tk.Canvas, schedule, root_tracker, tkschedule): self._c = c self._scroll = scroll self._schedule_frame = schedule_frame self._schedule = schedule self._root_tracker = root_tracker self._tkschedule = tkschedule self._frame = tk.Frame(self._schedule_frame) for i in range(self.COLSPAN): self._frame.columnconfigure(i, weight=1, uniform='course') self._assignments_widgets = dict() # initializes the name frame and label name_frame = tk.Frame(self._frame) name_frame.grid(row=0, column=0, sticky=tk.EW) for i in range(2): name_frame.columnconfigure(i, weight=1, uniform='name') self._name = utils.create_label(name_frame, self._c.name, 0, 1, sticky=tk.W) # initializes the course info self._units = utils.create_label(self._frame, self._c.units, 0, 1, padx=0) self._amt = utils.create_label(self._frame, len(self._c.assignments), 0, 2, padx=0) self._grade = utils.create_label(self._frame, self._c.grade, 0, 3, padx=0) # initializes the course drop down self._course_frame = tk.Frame(self._frame) self._course_frame.grid(row=1, column=0, columnspan=self.COLSPAN, sticky=tk.NSEW) utils.configure_frame(self._course_frame, rowspan=2, colspan=1) self._course_frame.grid_remove() # initializes the options frame options_frame = utils.create_labelframe(self._course_frame, 'Options', 0, 0) utils.configure_frame(options_frame, colspan=4) utils.create_button(options_frame, 'Add Assignment', self._create_assignment, 0, 0) utils.create_button(options_frame, 'Edit Course', self._edit_course, 0, 1) utils.create_button(options_frame, 'Submit Course', self._submit_course, 0, 2) utils.create_button(options_frame, 'Remove Course', self._remove_tkcourse, 0, 3) # initializes the assignments frame self._assignments_frame = utils.create_labelframe( self._course_frame, 'Assignments', 1, 0) for i in range(self.A_COLSPAN): self._assignments_frame.columnconfigure(i, weight=1, uniform='assignment') # initializes the drop down button icon = tk.Button(name_frame, command=lambda: self._course_menu(icon), width=16, height=16) utils.set_widget_image(icon, 'res/arrow.png', 2, 2) icon['border'] = '0' icon.state = 'hidden' icon.grid(row=0, column=0) if len(self._c.assignments) < 1: self._clear_assignments_info() else: self._init_assignments_info() for i in range(len(self._c.assignments)): self._update_tkassignment(self._c.assignments[i], i + 1) utils.create_separator(self._frame, 2, 0, self.COLSPAN, 0, 5)