コード例 #1
0
    def unpackTask(s, packedTask):

        # Unpack the task info into its components.
        unpacked = json.loads(packedTask)

        # Convert the job and app contexts to an instances of the Context class.
        ctx = Context(unpacked['ctx'])
        appCtx = Context(ctx.app)

        # Replace ctx.app as a dict with the appCtx Context class instance.
        ctx.app = appCtx

        return unpacked['operation'], unpacked['parms'], ctx
コード例 #2
0
def reflectionRequest():
    """
    JSON post example
    {
        dataType : "dataTypePointsToAFileInReflectionConfig"
        layout : "layoutTheToMapWillOpenUpOn"
        toMap : "mapToViewReflection"
        map : "Pancan12/SampleMap",
        nodeIds : [id, id, ...],
        rankCategories: True/False,
        dynamicAttrName : "Kindey Isle"
        email: [email protected]
    };
    JSON response on Success from job queue:
        {
            url : "http://aLong/UrlForTheClient/ToViewReflectionOnAMap"
            dataRetrievalUrl : HUB_URL/reflect/attrId/<string:fileId>,
            nNodes : 123
        }
        dataRetrievalUrl is an enpoint to download the calculated file.
        "url" will open a map viewer with the reflection in your
        browser.
        nNodes is the number of nodes there was data for when
        calculating reflection.
    """
    logging.info('Reflection requested')

    parms = validatePost()
    ctx = Context({'app': appCtx})

    responseDict = reflect_web.preCalc(parms, ctx)
    logging.info(responseDict)

    raise SuccessResp(responseDict)
コード例 #3
0
def oneByAllLeesLRequest():
    """
    Post example:
    {
        map : "PancanAtlas/SampleMap",
        focusAttr: opts.dynamicData,
        layoutIndex : 1,
        email : Meteor.user().username,
    };
    focusAttr is in this form:
        {"attrName" : { "sampleId" : value}, ... }

    JSON response on Success from job queue:
        {result:
            [
                [ attributeId, leesL, Rank, Pearson],
                ...,
                ...
            ]
        }
        For all attributes on the requested map.
    """
    logging.info('One By All LeesL requested')

    parms = validatePost()
    ctx = Context({'app': appCtx})

    responseDict = statsLayout_web.preCalc(parms, ctx)
    logging.info(responseDict)

    raise SuccessResp(responseDict)
コード例 #4
0
def oneByAllStatRequest():
    """
    Post example:
    {
        map : "PancanAtlas/SampleMap",
        focusAttr: opts.dynamicData,
        focusAttrDatatype : dType,
        email : Meteor.user().username,
    };
    focusAttr is in this form:
        {"attrName" : { "sampleId" : value}, ... }
    focus attribute datatype is one of:
        ["bin", "cat", "cont"]

    JSON response on Success from job queue:
        {result:
            [
                [ attributeId, single-test pvalue, BHFDR, bonefonni],
                ...,
                ...
            ]
        }
        For all attributes on the requested map.
    """
    logging.info('One By All Stat requested')

    parms = validatePost()
    ctx = Context({'app': appCtx})

    responseDict = statsNoLayout_web.preCalc(parms, ctx)
    logging.info(responseDict)

    raise SuccessResp(responseDict)
コード例 #5
0
    def test_single_node_individual_urls_false(s):

        # Test that _postCalc() knows how to compose a bookmark from this data
        # returned from the calc routine.

        # Build the data input to the calc routine.
        dataIn = {
            'map': 'unitTest/layoutBasicExp',
            'layout': 'mRNA',
            'individualUrls': False,
            'nodes': {
                'newNode1': {
                    'TP53': 0.54,
                    'ALK': 0.32,
                },
            },
        }

        # Build the calc result.
        ctx = Context({
            'app': appCtx,
            'dataIn': dataIn,
            'layoutIndex': 0,
        })
        result = {
            'nodes': {
                'newNode1': {
                    'x': 73,
                    'y': 91,
                    'neighbors': {
                        'TCGA-BP-4790': 0.352,
                        'TCGA-AK-3458': 0.742,
                    }
                }
            }
        }
        status, result = placeNode_web._postCalc(result, ctx)
        #print 'result:', result
        data = result

        s.assertTrue('newNode1' in data['nodes'])
        s.assertTrue('x' in data['nodes']['newNode1'])
        s.assertTrue(data['nodes']['newNode1']['x'] == 73)
        s.assertTrue('neighbors' in data['nodes']['newNode1'])
        s.assertTrue('TCGA-BP-4790' in data['nodes']['newNode1']['neighbors'])
        s.assertTrue(data['nodes']['newNode1']['neighbors']['TCGA-BP-4790'] == \
            0.352)
        bookmarkParm = '/?bookmark='
        sLen = len(s.viewServer) + len(bookmarkParm)
        s.assertTrue(data['nodes']['newNode1']['url'][:sLen] == \
            s.viewServer + bookmarkParm)
コード例 #6
0
import datetime
import json, requests, time

import www
import unittest
import testUtil as util
from jobQueue import JobQueue
from util_web import Context

# TODO create a dir: out
testDir = os.getcwd()
quePath = os.path.join(os.getcwd(), 'out/jobQueue.db')  # database file name
serverQueuePath = os.path.join(os.environ['HEXCALC'],
                               '../computeDb/jobQueue.db')
serverRoot = 'http://'
appCtx = Context({})
serverRoot += os.environ['WWW_SOCKET']

# Results
result1 = {'myResult': 'result1'}
result1unicode = json.loads(json.dumps(result1))

# Error message
errorMsg1 = {"error": "some error"}
errorMsg1trace = {"error": "some error", "stackTrace": "some stackTrace"}

# Seconds to wait for test job to complete
wait = 0.2

retryLimit = 10
コード例 #7
0
def queryPlaceNodeRoute():
    raise SuccessResp(
        placeNode_web.preCalc(validatePost(), Context({'app': appCtx})))
コード例 #8
0
def queryOverlayNodesRoute():
    raise SuccessResp(placeNode_web.preCalc(validatePost(),
        Context({'app': appCtx, 'overlayNodes': True})))
コード例 #9
0
def queryCreateMapRoute():
    raise SuccessResp(
        createMap_web.preCalc(validatePost(), Context({'app': appCtx })))
コード例 #10
0
def queryJobTestHelperRoute():
    raise SuccessResp(
        jobTestHelper_web.preCalc(validatePost(), Context({'app': appCtx})))
コード例 #11
0
#!/usr/bin/env python2.7

# This tests the dataset database functionality.

import os
import unittest
from util_web import Context
import cellDbInit
import cellDbDataset

testDir = os.path.join(os.environ.get('HEXCALC'), 'www/cellDb/tests')
appCtxDict = {
    'databasePath': os.path.join(testDir, 'out'),
}
appCtx = Context(appCtxDict)
dbPath = os.path.join(appCtx.databasePath, 'cell.db')

data = [
    [
        'Immune Bone', 'immune bone', 'human', 378000, 'd', 'd', 'd', 'd', 'd',
        'd', 'd', 'd', 'd', 'd', 'd'
    ],
    [
        'Hemotopoietic', 'blood', 'human', 681, 'd', 'd', 'd', 'd', 'd', 'd',
        'd', 'd', 'd', 'd', 'd'
    ],
    [
        'Tabula Muris droplet',
        'Bladder, Heart_and_Aorta, Kidney, Limb_Muscle, Liver, Lung, Mammary_Gland, Marrow, Spleen, Thymus, Tongue, Trachea',
        'mouse: Tabula Muris', 70118, 'd', 'd', 'd', 'd', 'd', 'd', 'd', 'd',
        'd', 'd', 'd'
コード例 #12
0
quePath = os.path.join(os.getcwd(), 'out/jobQueue.db')  # database file name

# Job context
ctx2 = 'ctx2'
ctx3 = 'ctx3'

jobStatusUrl = 'http://127.0.0.1:5000/jobStatus/jobId/'

appCtxDict = {
    'dev': int(os.environ.get('DEV', 0)),
    'jobQueuePath': quePath,
    'jobStatusUrl': jobStatusUrl,
    'unitTest': True,
    'adminEmail': '[email protected]',
}
appCtx = Context(appCtxDict)
appCtxUnicode = json.loads(json.dumps(appCtxDict))

ctx1NoAppUnicode = json.loads(json.dumps({'email': 'user1', 'prop1': 1}))
ctxdict = {'app': appCtx}
ctx1 = Context(ctxdict)
ctx1.prop1 = 1
ctx2 = Context(ctxdict)
ctx2.prop2 = 2
ctx3 = Context(ctxdict)
ctx3.prop3 = 3

# Tasks to execute as stored in the queue.
task1 = '{"ctx":{"app":{"adminEmail":"[email protected]","dev":' + str(
    appCtx.dev
) + ',"jobQueuePath":"' + quePath + '","jobStatusUrl":"' + jobStatusUrl + '","unitTest":true},"email":"user1","prop1":1},"operation":"jobTestHelper","parms":{"parms1":"parms1"}}'
コード例 #13
0
 def makeRequest(s, name, size):
     fileObj = Context({ 'filename': name, 'size': size })
     return Context({ 'files': { 'file': fileObj } })
コード例 #14
0
jobStatusUrl = 'http://127.0.0.1:5000/jobStatus/jobId/'

appCtxDict = {
    'adminEmail': os.environ.get('ADMIN_EMAIL'),
    'dataRoot': 'in/dataRoot',
    'debug': os.environ.get('DEBUG', 0),
    'dev': int(os.environ.get('DEV', 0)),
    'hubPath': os.environ.get('HEXCALC'),
    'jobQueuePath': quePath,
    'jobStatusUrl': jobStatusUrl,
    'unitTest': int(os.environ.get('UNIT_TEST', 0)),
    'viewServer': os.environ.get('VIEWER_URL', 'http://hexdev.sdsc.edu'),
}
appCtxDict['jobQueuePath'] = os.path.join(quePath)
appCtxDict['viewDir'] = os.path.join(appCtxDict['dataRoot'], 'view')
appCtx = Context(appCtxDict)
appCtxUnicode = json.loads(json.dumps(appCtxDict))
ctx1NoAppUnicode = json.loads(json.dumps({'prop1': 1}))
ctxdict = {'app': appCtx}
ctx1 = Context(ctxdict)
ctx1.prop1 = 1


class Test_placeNode(unittest.TestCase):

    # This view server must be running for these tests.
    viewServer = os.environ['VIEWER_URL']
    unprintable = '09'.decode('hex')  # tab character

    def setUp(self):
        self.app = www.app.test_client()