def hashe2signature(self, hashe_raw): hashe = hashtools.hashe_replace_object(hashe_raw, None, "None") log("hashe:", hashe) if isinstance(hashe, tuple): if hashe[0] == "analysis": return hashe[2] + ":" + hashtools.shhash(hashe)[:8] sig = hashtools.shhash(hashe)[:8] log("signature hashe:", sig) return sig
def hashe2signature(self,hashe_raw): hashe= hashtools.hashe_replace_object(hashe_raw, None, "None") log("hashe:",hashe) if isinstance(hashe,tuple): if hashe[0]=="analysis": return hashe[2]+":" + hashtools.shhash(hashe)[:8] sig= hashtools.shhash(hashe)[:8] log("signature hashe:",sig) return sig
def get_version(self): version = self.get_signature() + "." + self.version if self.autoversion and hasattr(self, 'catalog'): version += ".%i" % len(self.catalog) c_v = [] for e in sorted(self.catalog, key=lambda x: x['NAME']): e_v = [] for k, v in sorted(e.items()): if k == "NAME": e_v.append("%s_%s" % (str(k), str(v))) elif isinstance(v, float): e_v.append("%s_%.5lg" % (str(k), v)) elif isinstance(v, int): e_v.append("%s_%i" % (str(k), v)) else: e_v.append("%s_%s" % (str(k), str(v))) c_v.append("_".join(e_v)) cvs = ".".join(c_v) version += "." + cvs[:100] + "_" + shhash(cvs)[:8] return version
def hash_to_path2(hashe): #by32=lambda x:x[:8]+"/"+by8(x[8:]) if x[8:]!="" else x return hashe[2] + "/" + hashtools.shhash(repr(hashe[1]))
def find_entry(self): if hasattr(self, 'input_scw') and hasattr(self.input_scw, 'get_t1_t2'): t1, t2 = self.input_scw.get_t1_t2() revid = self.input_scw.input_scwid.str()[:4] else: t1 = 5000 t2 = 5000 revid = "None" idxfn = self.input_ic.icroot + "/idx/ic/" + self.ds + "-IDX.fits" print("idx:", idxfn) idx_hash = hashtools.shhash(open(idxfn).read())[:8] idx = fits.open(idxfn)[1].data print(t1, t2, zip(idx['VSTART'], idx['VSTOP'])) m_on = (idx['VSTART'] < t1) & (idx['VSTOP'] > t2) & (idx['VERSION'] == self.icversion) print("found valid:", sum(m_on)) print(idx[m_on]) order = np.argsort(idx[m_on]['VSTART']) member_location_rel = idx[m_on]['MEMBER_LOCATION'][order[-1]] print("newest", member_location_rel) member_location = os.path.abspath( os.path.dirname(idxfn) + "/" + member_location_rel) assert os.path.exists(member_location) version_fn = os.path.dirname( member_location) + "/.version." + os.path.basename(member_location) print("version file", version_fn) rev_hashe = ddosa.Revolution(input_revid=revid).get_hashe() if os.path.exists(version_fn): print("found hashe file at", version_fn) try: ic_hashe = ast.literal_eval(open(version_fn).read()) print("searching", ic_hashe, rev_hashe) if hashtools.find_object(ic_hashe, rev_hashe): ic_hashe_norev = hashtools.hashe_replace_object( ic_hashe, rev_hashe, '') print("norev hashe", ic_hashe_norev) else: print("unable to convert version file") return dict(hashe=ic_hashe, ds=self.ds, member_location=member_location, idx_hash=idx_hash, idxfn=idxfn) except IOError as e: print("unable to read version file, skipping", e) except SyntaxError as e: print("unable to read version file, skipping", e) print("found no version") return dict(hashe="UNDEFINED", ds=self.ds, member_location=member_location, idx_hash=idx_hash, idxfn=idxfn)
def hash_to_path2(hashe): #by32=lambda x:x[:8]+"/"+by8(x[8:]) if x[8:]!="" else x return hashe[2]+"/" + hashtools.shhash(repr(hashe[1]))