Extract the checkpoints and store in self.tracking_data
355880
def Extract_Checkpoints(self):
		'''
			
		'''

		# Make sure page is available
		if self.page is None:
			raise Exception("The HTML data was not fetched due to some reasons")

		# Check for invalid tracking number
		if 'Numbers Not Found -'in self.page or 'Invalid Query Numbers -' in self.page:
			raise ValueError('The Tracking number is invalid')

		soup = BeautifulSoup(self.page,'html.parser')

		# Assign the current status of the shipment
		if 'Returned To Origin' in self.page:		 # Prioritise this first
			self.status = 'R'
		elif 'SHIPMENT DELIVERED' in self.page:	 # If the above is false, only then check for this
			self.status = 'C'
		else:											 # The shipment is in Transit
			self.status = 'T'						

		# Checkpoints extraction begins here 
		cells = []

		'''
			The below for loop goes through the table of checkpoints adding relevant cell data to cells[]
		'''

		for cell in soup.findAll('td', {"align" : "LEFT"}):
		    if cell.font["size"] == '1':
		    	cell_text = cell.font.string
		    	if self.is_valid(cell_text):
		    		cells.append(cell_text)

		# 4 cells in each row
		rows = [cells[cell:cell + 4] for cell in xrange(0, len(cells), 4)]

		for row in rows:

			'''
				Each row will have 4 columns: Location--Status--Date--Time
				Merge column three and four and format it. 
				Append to tracking_data list
			'''

			location = row[0]
			status = row[1]
			date_time = ' '.join((row[2],row[3]))
			date_time_format = "%d-%b-%Y %H:%M"
			date_time = datetime.strptime(date_time,date_time_format)

			self.tracking_data.append({'status':status,'date':date_time,'location':location})

		# Sort the checkpoints based on Date and Time --- this is important
		self.tracking_data = sorted(self.tracking_data, key=lambda k: k['date'])
604495
def checkpoint(self, epoch_info: EpochInfo, model: Model):
        
        self.clean(epoch_info.global_epoch_idx - 1)

        self._make_sure_dir_exists()

        # Checkpoint latest
        torch.save(model.state_dict(), self.checkpoint_filename(epoch_info.global_epoch_idx))

        hidden_state = epoch_info.state_dict()
        self.checkpoint_strategy.write_state_dict(hidden_state)

        torch.save(hidden_state, self.checkpoint_hidden_filename(epoch_info.global_epoch_idx))

        if epoch_info.global_epoch_idx > 1 and self.checkpoint_strategy.should_delete_previous_checkpoint(
                                                   epoch_info.global_epoch_idx):
            prev_epoch_idx = epoch_info.global_epoch_idx - 1

            os.remove(self.checkpoint_filename(prev_epoch_idx))
            os.remove(self.checkpoint_hidden_filename(prev_epoch_idx))

        if self.checkpoint_strategy.should_store_best_checkpoint(epoch_info.global_epoch_idx, epoch_info.result):
            best_checkpoint_idx = self.checkpoint_strategy.current_best_checkpoint_idx

            if best_checkpoint_idx is not None:
                os.remove(self.checkpoint_best_filename(best_checkpoint_idx))

            torch.save(model.state_dict(), self.checkpoint_best_filename(epoch_info.global_epoch_idx))

            self.checkpoint_strategy.store_best_checkpoint_idx(epoch_info.global_epoch_idx)

        self.backend.store(epoch_info.result)
775016
def Extract_Checkpoints(self):
		'''
			
		'''

		# Make sure page is available
		if self.page is None:
			raise Exception("The HTML data was not fetched due to some reasons")

		soup = BeautifulSoup(self.page,'html.parser')

		invalid_tracking_no = soup.find('span',{'id':'ctl00_ContentPlaceHolder1_lblsMsg','class':'ErrorMessage','style':'font-family:Calibri;font-size:9pt;font-weight:bold;','name':'lblsMsg'})
		if invalid_tracking_no is not None:
			raise ValueError('The Tracking number is invalid')

		# Assign the current status of the shipment

		if 'Delivered' in self.page:
			self.status = 'C'
		else:											 # The shipment is in Transit
			self.status = 'T'						

		# Checkpoints extraction begins here 
		
		rows = soup.findAll('tr',{'class':'gridItem'}) + soup.findAll('tr',{'class':'gridAltItem'})

		for row in rows:

			'''
				Each row will have 4 columns: Date--Time--Status--Location
				Merge column one and two and format it. 
				Append to tracking_data list
			'''
			row_cells = row.findAll('td')

			date = row_cells[0].string.strip()
			time = row_cells[1].string.strip()
			date_time = ' '.join([date,time])
			date_time_format = "%d %b %Y %H:%M"
			date_time = datetime.strptime(date_time,date_time_format)
			status = row_cells[2].string.strip()
			location = row_cells[3].string.strip()
			
			self.tracking_data.append({'status':status,'date':date_time,'location':location})

		# Sort the checkpoints based on Date and Time --- this is important
		self.tracking_data = sorted(self.tracking_data, key=lambda k: k['date'])
321553
def _variant_sv(checkpoints):
    
    if not checkpoints.get("sv"):
        return [], []
    sv = [s("detect_sv", "batch-single",
            [["sv_batch_rec"]],
            [cwlout("sv_rec", "record",
                    fields=[cwlout(["sv", "variantcaller"], ["string", "null"]),
                            cwlout(["sv", "vrn_file"], ["File", "null"], [".tbi"]),
                            cwlout(["sv", "supplemental"], {"type": "array", "items": ["File"]}),
                            cwlout(["svvalidate", "summary"], ["File", "null"]),
                            cwlout("inherit", exclude=[["align_bam"], ["work_bam_plus"],
                                                       ["reference", "snpeff"]])])],
            "bcbio-vc", ["bedtools", "cnvkit", "delly", "duphold", "extract-sv-reads", "gsort",
                         "lumpy-sv;env=python2", "manta;env=python2", "break-point-inspector", "mosdepth", "samtools",
                         "smoove;env=python2", "pysam>=0.13.0",
                         "seq2c", "simple_sv_annotation;env=python2", "survivor", "svtools;env=python2",
                         "svtyper;env=python2",
                         "r=3.5.1", "r-base", "xorg-libxt", "vawk;env=python2"],
            disk={"files": 2.0})]
    sv_batch_inputs = [["analysis"], ["genome_build"],
                       ["work_bam_plus", "disc"], ["work_bam_plus", "sr"],
                       ["config", "algorithm", "background", "cnv_reference"],
                       ["config", "algorithm", "tools_on"],
                       ["config", "algorithm", "tools_off"],
                       ["config", "algorithm", "svprioritize"],
                       ["config", "algorithm", "svvalidate"], ["regions", "sample_callable"],
                       ["genome_resources", "variation", "gc_profile"],
                       ["genome_resources", "variation", "germline_het_pon"],
                       ["genome_resources", "aliases", "snpeff"], ["reference", "snpeff", "genome_build"],
                       ["sv_coverage_rec"]]
    if checkpoints.get("vc"):
        sv_batch_inputs.append(["variants", "samples"])
    steps = [s("calculate_sv_bins", "multi-combined",
               [["align_bam"], ["reference", "fasta", "base"],
                ["metadata", "batch"], ["metadata", "phenotype"],
                ["config", "algorithm", "background", "cnv_reference"],
                ["config", "algorithm", "callable_regions"],
                ["config", "algorithm", "coverage_interval"],
                ["config", "algorithm", "exclude_regions"],
                ["config", "algorithm", "sv_regions"],
                ["config", "algorithm", "variant_regions"],
                ["config", "algorithm", "variant_regions_merged"],
                ["config", "algorithm", "seq2c_bed_ready"],
                ["config", "algorithm", "svcaller"],
                ["depth", "variant_regions", "regions"],
                ["genome_resources", "variation", "lcr"], ["genome_resources", "variation", "polyx"],
                ["genome_resources", "variation", "encode_blacklist"],
                ["genome_resources", "rnaseq", "gene_bed"]],
               [cwlout("sv_bin_rec", "record",
                       fields=[cwlout(["regions", "bins", "target"], ["File", "null"]),
                               cwlout(["regions", "bins", "antitarget"], ["File", "null"]),
                               cwlout(["regions", "bins", "gcannotated"], ["File", "null"]),
                               cwlout(["regions", "bins", "group"], ["string", "null"]),
                               cwlout("inherit")])],
               "bcbio-vc", ["bedtools", "cnvkit"],
               disk={"files": 1.5}, cores=1),
             s("calculate_sv_coverage", "multi-parallel",
               [["sv_bin_rec"]],
               [cwlout("sv_rawcoverage_rec", "record",
                       fields=[cwlout(["depth", "bins", "target"], ["File", "null"]),
                               cwlout(["depth", "bins", "antitarget"], ["File", "null"]),
                               cwlout(["depth", "bins", "seq2c"], ["File", "null"]),
                               cwlout("inherit")])],
               "bcbio-vc", ["mosdepth", "cnvkit", "seq2c"],
               disk={"files": 1.5}),
             s("normalize_sv_coverage", "multi-combined",
               [["sv_rawcoverage_rec"]],
               [cwlout("sv_coverage_rec", "record",
                       fields=[cwlout(["depth", "bins", "normalized"], ["File", "null"]),
                               cwlout(["depth", "bins", "background"], ["File", "null"]),
                               cwlout("inherit")])],
               "bcbio-vc", ["cnvkit"],
               disk={"files": 1.5}),
             s("batch_for_sv", "multi-batch", sv_batch_inputs,
               [cwlout("sv_batch_rec", "record")],
               "bcbio-vc",
               unlist=[["config", "algorithm", "svcaller"]]),
             w("svcall", "multi-parallel", sv, []),
             s("summarize_sv", "multi-combined",
               [["sv_rec"]],
               [cwlout(["sv", "calls"], {"type": "array", "items": ["File", "null"]}),
                cwlout(["sv", "supplemental"], {"type": "array", "items": ["File"]}),
                cwlout(["sv", "prioritize", "tsv"], {"type": "array", "items": ["File", "null"]}),
                cwlout(["sv", "prioritize", "raw"], {"type": "array", "items": ["File", "null"]}),
                cwlout(["svvalidate", "grading_summary"], ["File", "null"]),
                cwlout(["svvalidate", "grading_plots"], {"type": "array", "items": ["File", "null"]})],
               "bcbio-vc", ["bcbio-prioritize"], disk={"files": 1.0}, cores=1)]
    final_outputs = [["sv", "calls"], ["svvalidate", "grading_summary"], ["sv", "prioritize", "tsv"],
                     ["sv", "prioritize", "raw"], ["sv", "supplemental"]]
    return steps, final_outputs
1105038
def save_checkpoint(self, config, population, species_set, generation):
        
        filename = '{0}{1}'.format(self.filename_prefix, generation)
        print("Saving checkpoint to {0}".format(filename))

        with gzip.open(filename, 'w', compresslevel=5) as f:
            data = (generation, config, population, species_set, random.getstate())
            pickle.dump(data, f, protocol=pickle.HIGHEST_PROTOCOL)
642028
def get_checkpoints_for_actor(actor_id):
    
    checkpoint_info = ray.worker.global_state.actor_checkpoint_info(actor_id)
    if checkpoint_info is None:
        return []
    checkpoints = [
        Checkpoint(checkpoint_id, timestamp) for checkpoint_id, timestamp in
        zip(checkpoint_info["CheckpointIds"], checkpoint_info["Timestamps"])
    ]
    return sorted(
        checkpoints,
        key=lambda checkpoint: checkpoint.timestamp,
        reverse=True,
    )
187261
async def Track(self, payloads):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='PayloadsHookContext',
                   request='Track',
                   version=1,
                   params=_params)
        _params['payloads'] = payloads
        reply = await self.rpc(msg)
        return reply
128997
def _read_checkpoint_vars(model_path):
        
        reader = tf.train.NewCheckpointReader(model_path)
        reader = CheckpointReaderAdapter(reader)    # use an adapter to standardize the name
        ckpt_vars = reader.get_variable_to_shape_map().keys()
        return reader, set(ckpt_vars)
92600
def read_tf_checkpoint(path):
    """"""
    from tensorflow.python import pywrap_tensorflow
    tensors = {}
    reader = pywrap_tensorflow.NewCheckpointReader(path)
    var_to_shape_map = reader.get_variable_to_shape_map()
    for key in sorted(var_to_shape_map):
        tensor = reader.get_tensor(key)
        tensors[key] = tensor
    return tensors
410180
@Override
	public CheckpointData getCheckpointData(CheckpointDataKey key) {
		logger.entering(CLASSNAME, "getCheckpointData", key==null ? "<null>" : key);
		CheckpointData checkpointData = queryCheckpointData(key.getCommaSeparatedKey());
		logger.exiting(CLASSNAME, "getCheckpointData", checkpointData==null ? "<null>" : checkpointData);
		return checkpointData;
	}
394426
async def find(self, *tracking_numbers: str) -> list:
        """"""
        data = {'data': [{'num': num} for num in tracking_numbers]}
        tracking_resp = await self._request('post', API_URL_TRACK, json=data)

        print(tracking_resp)

        if not tracking_resp.get('dat'):
            raise InvalidTrackingNumberError('Invalid data')

        packages = []
        for info in tracking_resp['dat']:
            package_info = info.get('track', {})

            if not package_info:
                continue

            kwargs = {
                'destination_country': package_info.get('c'),
                'info_text': package_info.get('z0', {}).get('z'),
                'location': package_info.get('z0', {}).get('c'),
                'origin_country': package_info.get('b'),
                'package_type': package_info.get('d', 0),
                'status': package_info.get('e', 0),
                'tracking_info_language': package_info.get('ln1', 'Unknown')
            }
            packages.append(Package(info['no'], **kwargs))
        return packages
85343
def _track_stack_pointers(self):
        

        regs = {self.project.arch.sp_offset}
        if hasattr(self.project.arch, 'bp_offset') and self.project.arch.bp_offset is not None:
            regs.add(self.project.arch.bp_offset)
        spt = self.project.analyses.StackPointerTracker(self.function, regs, track_memory=self._sp_tracker_track_memory)
        if spt.inconsistent_for(self.project.arch.sp_offset):
            l.warning("Inconsistency found during stack pointer tracking. Decompilation results might be incorrect.")
        return spt
1289467
function createTrackerEntity(data) {

    let result = data.results[0]

    return new TrackerInfo({
        attempts: 1,
        id: result.id,
        transportType: result.type,
        origin: result.origin.value,
        destiny: result.destination.value,
        states: result.checkpoints.map((elem) => {
            let date = elem.date.trim() + " " + elem.time.trim()
            return {
                state: elem.description.trim(),
                date: moment.tz(date, "dddd, MMMM DD, YYYY HH:mm", 'pt', zone).format(),
                area: elem.location.trim()
            }
        })
    })
}
1224512
def collect_results(self) -> Optional[Tuple[int, Dict[str, float]]]:
        
        self.wait_to_finish()
        if self.decoder_metric_queue.empty():
            if self._results_pending:
                self._any_process_died = True
            self._results_pending = False
            return None
        decoded_checkpoint, decoder_metrics = self.decoder_metric_queue.get()
        assert self.decoder_metric_queue.empty()
        self._results_pending = False
        logger.info("Decoder-%d finished: %s", decoded_checkpoint, decoder_metrics)
        return decoded_checkpoint, decoder_metrics
820551
def advance_to_checkpoint(self, checkpoint):
        
        if checkpoint in self._checkpoints:
            for cp in self._checkpoints:
                self.insert(cp)
                if cp == checkpoint:
                    return cp
        else:
            raise InvalidCheckpointError(checkpoint)
495213
def should_store_best_checkpoint(self, epoch_idx, metrics) -> bool:
        
        if not self.store_best:
            return False

        metric = metrics[self.metric]

        if better(self._current_best_metric_value, metric, self.metric_mode):
            self._current_best_metric_value = metric
            return True

        return False
1302163
def _load_track_estimates(track, estimates_dir, output_dir):
    """"""
    user_results = {}
    track_estimate_dir = os.path.join(
        estimates_dir,
        track.subset,
        track.name
    )
    for target in glob.glob(
        track_estimate_dir + '/*.wav'
    ):

        target_name = op.splitext(
            os.path.basename(target)
        )[0]
        try:
            target_audio, _ = sf.read(
                target,
                always_2d=True
            )
            user_results[target_name] = target_audio
        except RuntimeError:
            pass

    if user_results:
        eval_mus_track(
            track,
            user_results,
            output_dir=output_dir
        )

    return None