Submit reassignment plan for execution.
8524
def execute_plan(self, plan, allow_rf_change=False):
        """"""
        reassignment_path = '{admin}/{reassignment_node}'\
            .format(admin=ADMIN_PATH, reassignment_node=REASSIGNMENT_NODE)
        plan_json = dump_json(plan)
        base_plan = self.get_cluster_plan()
        if not validate_plan(plan, base_plan, allow_rf_change=allow_rf_change):
            _log.error('Given plan is invalid. Aborting new reassignment plan ... {plan}'.format(plan=plan))
            return False
        # Send proposed-plan to zookeeper
        try:
            _log.info('Sending plan to Zookeeper...')
            self.create(reassignment_path, plan_json, makepath=True)
            _log.info(
                'Re-assign partitions node in Zookeeper updated successfully '
                'with {plan}'.format(plan=plan),
            )
            return True
        except NodeExistsError:
            _log.warning('Previous plan in progress. Exiting..')
            _log.warning('Aborting new reassignment plan... {plan}'.format(plan=plan))
            in_progress_plan = load_json(self.get(reassignment_path)[0])
            in_progress_partitions = [
                '{topic}-{p_id}'.format(
                    topic=p_data['topic'],
                    p_id=str(p_data['partition']),
                )
                for p_data in in_progress_plan['partitions']
            ]
            _log.warning(
                '{count} partition(s) reassignment currently in progress:-'
                .format(count=len(in_progress_partitions)),
            )
            _log.warning(
                '{partitions}. In Progress reassignment plan...'.format(
                    partitions=', '.join(in_progress_partitions),
                ),
            )
            return False
        except Exception as e:
            _log.error(
                'Could not re-assign partitions {plan}. Error: {e}'
                .format(plan=plan, e=e),
            )
            return False
1153342
def move(self, new_location):
        """"""
        self._perform_change(change.MoveResource(self, new_location),
                             'Moving <%s> to <%s>' % (self.path, new_location))
336578
def submit(self):
        """"""
        if self.api._req_lixian_add_task_bt(self):
            self.submitted = True
            return True
        return False
806583
def assign_shifts_view(request, semester):
    
    page_name = "Assign Shifts"

    auto_assign_shifts_form = None
    random_assign_instances_form = None
    clear_assign_form = None

    if WorkshiftPool.objects.filter(semester=semester).count():
        auto_assign_shifts_form = AutoAssignShiftForm(
            data=request.POST if AutoAssignShiftForm.name in request.POST else None,
            semester=semester,
        )
        random_assign_instances_form = RandomAssignInstancesForm(
            data=request.POST if RandomAssignInstancesForm.name in request.POST else None,
            semester=semester,
        )
        clear_assign_form = ClearAssignmentsForm(
            data=request.POST if ClearAssignmentsForm.name in request.POST else None,
            semester=semester,
        )

    forms = [auto_assign_shifts_form, random_assign_instances_form,
             clear_assign_form]

    if auto_assign_shifts_form and auto_assign_shifts_form.is_valid():
        unassigned_profiles = auto_assign_shifts_form.save()
        message = "Assigned workshifters to regular workshifts."
        if unassigned_profiles:
            message += " The following workshifters were not given " \
              "complete assignments: "
            message += ", ".join(i.user.get_full_name() for i in unassigned_profiles)
        messages.add_message(request, messages.INFO, message)
        return HttpResponseRedirect(wurl(
            "workshift:assign_shifts",
            sem_url=semester.sem_url,
        ))

    if random_assign_instances_form and random_assign_instances_form.is_valid():
        unassigned_profiles, unassigned_shifts = \
          random_assign_instances_form.save()
        message = "Assigned workshifters randomly to instances within {}." \
          .format(random_assign_instances_form.cleaned_data["pool"])
        if unassigned_profiles:
            message += "The following workshifers were not given " \
              "complete assignments: "
            message += ", ".join(i.user.get_full_name() for i in unassigned_profiles)
        messages.add_message(request, messages.INFO, message)
        return HttpResponseRedirect(wurl(
            "workshift:assign_shifts",
            sem_url=semester.sem_url,
        ))

    if clear_assign_form and clear_assign_form.is_valid():
        clear_assign_form.save()
        messages.add_message(
            request,
            messages.INFO,
            "Cleared all workshifters from their regular workshift "
            "assignments",
        )
        return HttpResponseRedirect(wurl(
            "workshift:assign_shifts",
            sem_url=semester.sem_url,
        ))

    shifts = RegularWorkshift.objects.filter(
        pool__semester=semester,
        active=True,
    ).exclude(
        workshift_type__assignment=WorkshiftType.NO_ASSIGN,
    )

    assign_forms = []
    for shift in shifts:
        form = AssignShiftForm(
            data=request.POST if "individual_assign" in request.POST else None,
            prefix="shift-{}".format(shift.pk),
            instance=shift,
            semester=semester,
        )
        assign_forms.append(form)

    if assign_forms and all(i.is_valid() for i in assign_forms):
        for form in assign_forms:
            form.save()
        messages.add_message(
            request,
            messages.INFO,
            "Workshift assignments saved.",
        )
        return HttpResponseRedirect(wurl(
            "workshift:assign_shifts",
            sem_url=semester.sem_url,
        ))

    workshifters = WorkshiftProfile.objects.filter(semester=semester)
    pools = WorkshiftPool.objects.filter(semester=semester).order_by(
        "-is_primary", "title",
    )

    pool_hours = []
    for workshifter in workshifters:
        hours_owed = []
        for pool in pools:
            hours = workshifter.pool_hours.get(pool=pool)
            hours_owed.append(hours.hours - hours.assigned_hours)

        if any(i > 0 for i in hours_owed):
            pool_hours.append(hours_owed)

    total_pool_hours = [
        sum(hours[i] for hours in pool_hours)
        for i in range(len(pool_hours[0]) if len(pool_hours) > 0 else 0)
    ]

    return render_to_response("assign_shifts.html", {
        "page_name": page_name,
        "forms": forms,
        "assign_forms": assign_forms,
        "unassigned_profiles": zip(workshifters, pool_hours),
        "pools": pools,
        "total_pool_hours": total_pool_hours,
    }, context_instance=RequestContext(request))
196434
def reassign_label(cls, destination_cluster, label):
        
        conn = Qubole.agent(version=Cluster.api_version)
        data = {
                    "destination_cluster": destination_cluster,
                    "label": label
                }
        return conn.put(cls.rest_entity_path + "/reassign-label", data)
1131563
def _do_assign(self, spike_ids, new_spike_clusters):
        """"""

        # Ensure spike_clusters has the right shape.
        spike_ids = _as_array(spike_ids)
        if len(new_spike_clusters) == 1 and len(spike_ids) > 1:
            new_spike_clusters = (np.ones(len(spike_ids), dtype=np.int64) *
                                  new_spike_clusters[0])
        old_spike_clusters = self._spike_clusters[spike_ids]

        assert len(spike_ids) == len(old_spike_clusters)
        assert len(new_spike_clusters) == len(spike_ids)

        # Update the spikes per cluster structure.
        old_clusters = _unique(old_spike_clusters)

        # NOTE: shortcut to a merge if this assignment is effectively a merge
        # i.e. if all spikes are assigned to a single cluster.
        # The fact that spike selection has been previously extended to
        # whole clusters is critical here.
        new_clusters = _unique(new_spike_clusters)
        if len(new_clusters) == 1:
            return self._do_merge(spike_ids, old_clusters, new_clusters[0])

        # We return the UpdateInfo structure.
        up = _assign_update_info(spike_ids,
                                 old_spike_clusters,
                                 new_spike_clusters)

        # We update the new cluster id (strictly increasing during a session).
        self._new_cluster_id = max(self._new_cluster_id, max(up.added) + 1)

        # We make the assignments.
        self._spike_clusters[spike_ids] = new_spike_clusters
        # OPTIM: we update spikes_per_cluster manually.
        new_spc = _spikes_per_cluster(new_spike_clusters, spike_ids)
        self._update_cluster_ids(to_remove=old_clusters, to_add=new_spc)
        return up
1086258
public void fireAssignmentWrittenEvent(ResourceAssignment resourceAssignment)
   {
      if (m_projectListeners != null)
      {
         for (ProjectListener listener : m_projectListeners)
         {
            listener.assignmentWritten(resourceAssignment);
         }
      }
   }
457238
def resubmit(args):
  """"""
  jm = setup(args)

  kwargs = {
      'cwd': True,
      'verbosity' : args.verbose
  }
  if args.qname is not None:
    kwargs['queue'] = args.qname
  if args.memory is not None:
    kwargs['memfree'] = args.memory
    if args.qname not in (None, 'all.q'):
      kwargs['hvmem'] = args.memory
    # if this is a GPU queue and args.memory is provided, we set gpumem flag
    # remove 'G' last character from the args.memory string
    if args.qname in ('gpu', 'lgpu', 'sgpu', 'gpum') and args.memory is not None:
      kwargs['gpumem'] = args.memory
      # don't set these for GPU processing or the maximum virtual memroy will be
      # set on ulimit
      kwargs.pop('memfree', None)
      kwargs.pop('hvmem', None)
  if args.parallel is not None:
    kwargs['pe_opt'] = "pe_mth %d" % args.parallel
    kwargs['memfree'] = get_memfree(args.memory, args.parallel)
  if args.io_big:
    kwargs['io_big'] = True
  if args.no_io_big:
    kwargs['io_big'] = False

  jm.resubmit(get_ids(args.job_ids), args.also_success, args.running_jobs, args.overwrite_command, keep_logs=args.keep_logs, **kwargs)
315071
private Assignment createAssignment(
            IPermission permission, IAuthorizationPrincipal authP, boolean inherited) {

        Assignment rslt = null;

        try {

            // Owner
            IPermissionOwner owner = permissionOwnerDao.getPermissionOwner(permission.getOwner());
            Owner ownerImpl = new OwnerImpl(permission.getOwner(), owner.getName());

            // Activity
            IPermissionActivity activity =
                    permissionOwnerDao.getPermissionActivity(
                            permission.getOwner(), permission.getActivity());
            Activity activityImpl = new ActivityImpl(permission.getActivity(), activity.getName());

            // Principal
            Principal principalImpl = new PrincipalImpl(authP.getKey(), authP.getPrincipalString());

            // Target
            Target targetImpl = null; // default
            IPermissionTargetProvider targetProvider =
                    targetProviderRegistry.getTargetProvider(activity.getTargetProviderKey());
            IPermissionTarget target = targetProvider.getTarget(permission.getTarget());
            if (target != null) {
                targetImpl = new TargetImpl(permission.getTarget(), target.getName());
            }

            rslt =
                    new AssignmentImpl(
                            ownerImpl, activityImpl, principalImpl, targetImpl, inherited);

        } catch (Exception e) {
            log.warn("Exception while adding permission", e);
        }

        return rslt;
    }
532461
private void populateResourceAssignment(Record record, ResourceAssignment assignment) throws MPXJException
   {
      //
      // Handle malformed MPX files - ensure that we can locate the resource
      // using either the Unique ID attribute or the ID attribute.
      //
      Resource resource = m_projectFile.getResourceByUniqueID(record.getInteger(12));
      if (resource == null)
      {
         resource = m_projectFile.getResourceByID(record.getInteger(0));
      }

      assignment.setUnits(record.getUnits(1));
      assignment.setWork(record.getDuration(2));
      assignment.setBaselineWork(record.getDuration(3));
      assignment.setActualWork(record.getDuration(4));
      assignment.setOvertimeWork(record.getDuration(5));
      assignment.setCost(record.getCurrency(6));
      assignment.setBaselineCost(record.getCurrency(7));
      assignment.setActualCost(record.getCurrency(8));
      assignment.setStart(record.getDateTime(9));
      assignment.setFinish(record.getDateTime(10));
      assignment.setDelay(record.getDuration(11));

      //
      // Calculate the remaining work
      //
      Duration work = assignment.getWork();
      Duration actualWork = assignment.getActualWork();
      if (work != null && actualWork != null)
      {
         if (work.getUnits() != actualWork.getUnits())
         {
            actualWork = actualWork.convertUnits(work.getUnits(), m_projectFile.getProjectProperties());
         }

         assignment.setRemainingWork(Duration.getInstance(work.getDuration() - actualWork.getDuration(), work.getUnits()));
      }

      if (resource != null)
      {
         assignment.setResourceUniqueID(resource.getUniqueID());
         resource.addResourceAssignment(assignment);
      }

      m_eventManager.fireAssignmentReadEvent(assignment);
   }
855153
private void processAssignments() throws SQLException
   {
      List<Row> rows = getRows("select * from zscheduleitem where zproject=? and z_ent=? order by zorderinactivity", m_projectID, m_entityMap.get("Assignment"));
      for (Row row : rows)
      {
         Task task = m_project.getTaskByUniqueID(row.getInteger("ZACTIVITY_"));
         Resource resource = m_project.getResourceByUniqueID(row.getInteger("ZRESOURCE"));
         if (task != null && resource != null)
         {
            ResourceAssignment assignment = task.addResourceAssignment(resource);
            assignment.setGUID(row.getUUID("ZUNIQUEID"));
            assignment.setActualFinish(row.getTimestamp("ZGIVENACTUALENDDATE_"));
            assignment.setActualStart(row.getTimestamp("ZGIVENACTUALSTARTDATE_"));

            assignment.setWork(assignmentDuration(task, row.getWork("ZGIVENWORK_")));
            assignment.setOvertimeWork(assignmentDuration(task, row.getWork("ZGIVENWORKOVERTIME_")));
            assignment.setActualWork(assignmentDuration(task, row.getWork("ZGIVENACTUALWORK_")));
            assignment.setActualOvertimeWork(assignmentDuration(task, row.getWork("ZGIVENACTUALWORKOVERTIME_")));
            assignment.setRemainingWork(assignmentDuration(task, row.getWork("ZGIVENREMAININGWORK_")));

            assignment.setLevelingDelay(row.getDuration("ZLEVELINGDELAY_"));

            if (assignment.getRemainingWork() == null)
            {
               assignment.setRemainingWork(assignment.getWork());
            }

            if (resource.getType() == ResourceType.WORK)
            {
               assignment.setUnits(Double.valueOf(NumberHelper.getDouble(row.getDouble("ZRESOURCEUNITS_")) * 100.0));
            }
         }
      }
   }
360328
private void reassign() {
    if (member.type() == Member.Type.ACTIVE && !member.equals(context.getLeader())) {
      // Calculate this server's index within the collection of active members, excluding the leader.
      // This is done in a deterministic way by sorting the list of active members by ID.
      int index = 1;
      for (MemberState member : getActiveMemberStates((m1, m2) -> m1.getMember().id() - m2.getMember().id())) {
        if (!member.getMember().equals(context.getLeader())) {
          if (this.member.id() < member.getMember().id()) {
            index++;
          } else {
            break;
          }
        }
      }

      // Intersect the active members list with a sorted list of passive members to get assignments.
      List<MemberState> sortedPassiveMembers = getPassiveMemberStates((m1, m2) -> m1.getMember().id() - m2.getMember().id());
      assignedMembers = assignMembers(index, sortedPassiveMembers);
    } else {
      assignedMembers = new ArrayList<>(0);
    }
  }
984773
def commit(self):
        """"""
        self.send_buffered_operations()
        retry_until_ok(self.elastic.indices.refresh, index="")
603587
def add_assignment(self, value):
        """"""
        if not value in self._assignments:
            self._assignments.append(value)
606557
def allow_analyst_reassignment(self):
        
        reassing_analyst_transition = {
            "id": "reassign",
            "title": _("Reassign")}
        for rs in self.review_states:
            if rs["id"] not in ["default", "mine", "open", "all"]:
                continue
            rs["custom_transitions"].append(reassing_analyst_transition)
        self.show_select_column = True
        self.show_workflow_action_buttons = True
1006790
protected function updateAssignment()
    {
        $uri = str_replace('{assignment}', $this->assignment, config('forge-publish.update_assignment_uri'));
        $url = config('forge-publish.url') . $uri;
        try {
            $response = $this->http->put($url, [
                'form_params' => [
                    'name' => $this->assignmentName,
                    'repository_uri' => $this->repository_uri,
                    'repository_type' => $this->repository_type,
                    'forge_site' => $this->forge_site,
                    'forge_server' => $this->forge_server
                ],
                'headers' => [
                    'X-Requested-With' => 'XMLHttpRequest',
                    'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN')
                ]
            ]);
        } catch (\Exception $e) {
            $this->error('And error occurs connecting to the api url: ' . $url);
            $this->error('Status code: ' . $e->getResponse()->getStatusCode() . ' | Reason : ' . $e->getResponse()->getReasonPhrase());
            return [];
        }
        return json_decode((string) $response->getBody());
    }
851796
def on_assign(self, node):    # ('targets', 'value')
        """"""
        val = self.run(node.value)
        for tnode in node.targets:
            self.node_assign(tnode, val)
        return