Beispiel #1
0
def removeVersion(endpoint):

    va = sandVersion(endpoint)
    vb = lastVersion(endpoint, -1)

    if va == vb:
        return (False, 'no more removable versions')

    # check exposed version
    if not checkOldSynthax(endpoint):
        return (False, 'Unable to fix service-version.txt')

    ndir = wkd + '/' + endpoint
    if os.path.isfile(ndir + '/service-version.txt'):

        versions = []
        f = open(ndir + '/service-version.txt', 'r')
        versions = f.readlines()
        f.close()

        del versions[-1]
        f = open(ndir + '/service-version.txt', 'w')
        for vi in versions:
            f.write(vi)
        f.close()

    # remove directory
    try:
        shutil.rmtree(vb, ignore_errors=True)
    except:
        return (False, 'unable to remove ' + vb)

    return (True, 'version ' + vb + ' removed OK')
Beispiel #2
0
def removeVersion (endpoint):

    va = sandVersion (endpoint)
    vb = lastVersion (endpoint,-1)

    if va == vb:
        return (False, 'no more removable versions')

    # check exposed version
    if not checkOldSynthax (endpoint):
        return (False, 'Unable to fix service-version.txt')

    ndir = wkd +'/'+endpoint
    if os.path.isfile (ndir+'/service-version.txt'):

        versions = []
        f = open (ndir+'/service-version.txt','r')
        versions = f.readlines()
        f.close()

        del versions[-1]
        f = open (ndir+'/service-version.txt','w')
        for vi in versions:
            f.write (vi)
        f.close()   

    # remove directory
    try:
        shutil.rmtree (vb, ignore_errors=True)
    except:
        return (False, 'unable to remove '+vb)
    
    return (True,'version '+vb+' removed OK')
Beispiel #3
0
def publishVersion(endpoint, tag):
    """Top level buildind function

       molecules:  SDFile containing the collection of 2D structures to be predicted
       verID:      version of the model that will be used. Value -1 means the last one

    """

    # clone directory
    va = sandVersion(endpoint)
    vb = nextVersion(endpoint)

    if not va:
        return (False, "No versions directory found")

    if not checkOldSynthax(endpoint):
        return (False, 'Unable to fix service-version.txt')

    shutil.copytree(va, vb)

    if os.path.isfile(wkd + '/' + endpoint + '/service-version.txt'):
        f = open(wkd + '/' + endpoint + '/service-version.txt', 'a')
        f.write(str(int(vb[-4:])) + '\t0\n')
        f.close()

    if os.path.isfile(va + '/info.pkl'):
        modelInfo = open(vb + '/info.pkl', 'rb')
        infoID = pickle.load(modelInfo)
        infoSeries = pickle.load(modelInfo)
        infoMD = pickle.load(modelInfo)
        infoModel = pickle.load(modelInfo)
        infoResult = pickle.load(modelInfo)
        try:
            infoLocal = pickle.load(modelInfo)
        except:
            infoLocal = []
        modelInfo.close()

        for i in range(len(infoID)):
            if infoID[i][0] == 'version':
                infoID.remove(infoID[i])
                infoID.insert(i, ('version', int(vb[-4:])))

        # add the type of endpoint (quantitative or qualitative) after the tag
        # this is needed by views2 to publish appropriately the model type
        ndir = wkd + '/' + endpoint

        if not os.path.isfile(ndir + '/service-label.txt'):
            return (False, 'unable to open service-label.txt file')

        f = open(ndir + '/service-label.txt', 'r')
        tag = f.readline()
        f.close()

        if not tag: tag = 'none'
        infoID.append(('tag', tag[:-1]))

        modelInfo = open(vb + '/info.pkl', 'wb')
        pickle.dump(infoID, modelInfo)
        pickle.dump(infoSeries, modelInfo)
        pickle.dump(infoMD, modelInfo)
        pickle.dump(infoModel, modelInfo)
        pickle.dump(infoResult, modelInfo)
        pickle.dump(infoLocal, modelInfo)
        modelInfo.close()

        f = open(ndir + '/service-label.txt', 'w')
        f.write(tag)
        ytype = 'undefined'
        for i in infoID:
            if 'dependent' in i:
                ytype = i[1]
        f.write(ytype + '\n')
        f.close()

    else:
        ##return (False,"No suitable model found")
        pass

    return (True, vb)
Beispiel #4
0
def publishVersion (endpoint, tag):
    """Top level buildind function

       molecules:  SDFile containing the collection of 2D structures to be predicted
       verID:      version of the model that will be used. Value -1 means the last one

    """

    # clone directory
    va = sandVersion (endpoint)
    vb = nextVersion (endpoint)
    
    if not va:
        return (False,"No versions directory found")

    if not checkOldSynthax (endpoint):
            return (False, 'Unable to fix service-version.txt')
        
    shutil.copytree(va,vb)

    if os.path.isfile (wkd +'/'+endpoint+'/service-version.txt'):      
        f = open (wkd +'/'+endpoint+'/service-version.txt','a')
        f.write (str(int(vb[-4:]))+'\t0\n')
        f.close()   

    if os.path.isfile(va+'/info.pkl'):
        modelInfo = open (vb+'/info.pkl','rb')
        infoID = pickle.load(modelInfo)
        infoSeries = pickle.load(modelInfo)
        infoMD = pickle.load(modelInfo)
        infoModel = pickle.load(modelInfo)
        infoResult = pickle.load(modelInfo)        
        try:
            infoLocal=pickle.load(modelInfo)            
        except:
            infoLocal = []             
        modelInfo.close()
        
        for i in range(len(infoID)):
            if infoID[i][0]=='version': 
                infoID.remove (infoID[i])
                infoID.insert (i,('version', int (vb[-4:])))

        # add the type of endpoint (quantitative or qualitative) after the tag
        # this is needed by views2 to publish appropriately the model type
        ndir = wkd +'/'+endpoint

        if not os.path.isfile(ndir+'/service-label.txt'):
            return (False, 'unable to open service-label.txt file')
        
        f = open (ndir+'/service-label.txt','r')
        tag = f.readline()        
        f.close()
        
        if not tag: tag = 'none'
        infoID.append (('tag',tag[:-1]))

        modelInfo = open (vb+'/info.pkl','wb')
        pickle.dump(infoID, modelInfo)
        pickle.dump(infoSeries, modelInfo)
        pickle.dump(infoMD, modelInfo)
        pickle.dump(infoModel, modelInfo)
        pickle.dump(infoResult, modelInfo)
        pickle.dump(infoLocal, modelInfo)
        modelInfo.close()

        f = open (ndir+'/service-label.txt','w')
        f.write (tag)
        ytype='undefined'
        for i in infoID:
            if 'dependent' in i:
                    ytype = i[1]
        f.write (ytype+'\n')
        f.close()

    else:        
        ##return (False,"No suitable model found")
        pass

    return (True, vb)