code
string | signature
string | docstring
string | loss_without_docstring
float64 | loss_with_docstring
float64 | factor
float64 |
|---|---|---|---|---|---|
return DXHTTPRequest('/%s/close' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_close(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/close API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Data-Object-Lifecycle#API-method%3A-%2Fclass-xxxx%2Fclose
| 3.249319
| 4.012622
| 0.809774
|
return DXHTTPRequest('/%s/describe' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_describe(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/describe API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Records#API-method%3A-%2Frecord-xxxx%2Fdescribe
| 2.996892
| 3.395362
| 0.882643
|
return DXHTTPRequest('/%s/getDetails' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_get_details(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/getDetails API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Details-and-Links#API-method%3A-%2Fclass-xxxx%2FgetDetails
| 3.285627
| 3.441417
| 0.954731
|
return DXHTTPRequest('/%s/listProjects' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_list_projects(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/listProjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Cloning#API-method%3A-%2Fclass-xxxx%2FlistProjects
| 3.103227
| 3.870749
| 0.801712
|
return DXHTTPRequest('/%s/removeTags' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_remove_tags(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/removeTags API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FremoveTags
| 2.987292
| 3.734895
| 0.799833
|
return DXHTTPRequest('/%s/removeTypes' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_remove_types(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/removeTypes API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Types#API-method%3A-%2Fclass-xxxx%2FremoveTypes
| 2.999398
| 3.721841
| 0.805891
|
return DXHTTPRequest('/%s/rename' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_rename(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/rename API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Name#API-method%3A-%2Fclass-xxxx%2Frename
| 2.82496
| 3.711251
| 0.761188
|
return DXHTTPRequest('/%s/setDetails' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_set_details(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/setDetails API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Details-and-Links#API-method%3A-%2Fclass-xxxx%2FsetDetails
| 3.475237
| 3.34326
| 1.039476
|
return DXHTTPRequest('/%s/setProperties' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_set_properties(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/setProperties API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Properties#API-method%3A-%2Fclass-xxxx%2FsetProperties
| 3.0497
| 3.541262
| 0.86119
|
return DXHTTPRequest('/%s/setVisibility' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def record_set_visibility(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /record-xxxx/setVisibility API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Visibility#API-method%3A-%2Fclass-xxxx%2FsetVisibility
| 3.618025
| 3.964073
| 0.912704
|
return DXHTTPRequest('/system/describeDataObjects', input_params, always_retry=always_retry, **kwargs)
|
def system_describe_data_objects(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/describeDataObjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/System-Methods#API-method:-/system/describeDataObjects
| 3.448373
| 4.913497
| 0.701816
|
return DXHTTPRequest('/system/describeExecutions', input_params, always_retry=always_retry, **kwargs)
|
def system_describe_executions(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/describeExecutions API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/System-Methods#API-method:-/system/describeExecutions
| 3.508651
| 4.316011
| 0.812938
|
return DXHTTPRequest('/system/describeProjects', input_params, always_retry=always_retry, **kwargs)
|
def system_describe_projects(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/describeProjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/System-Methods#API-method:-/system/describeProjects
| 3.857428
| 4.527996
| 0.851906
|
return DXHTTPRequest('/system/findAffiliates', input_params, always_retry=always_retry, **kwargs)
|
def system_find_affiliates(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findAffiliates API method.
| 3.783201
| 3.340026
| 1.132686
|
return DXHTTPRequest('/system/findApps', input_params, always_retry=always_retry, **kwargs)
|
def system_find_apps(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findApps API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindApps
| 3.823913
| 5.232074
| 0.73086
|
return DXHTTPRequest('/system/findDataObjects', input_params, always_retry=always_retry, **kwargs)
|
def system_find_data_objects(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findDataObjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindDataObjects
| 3.656392
| 5.248327
| 0.696678
|
return DXHTTPRequest('/system/findGlobalWorkflows', input_params, always_retry=always_retry, **kwargs)
|
def system_find_global_workflows(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findGlobalWorkflows API method.
| 3.405236
| 3.041508
| 1.119588
|
return DXHTTPRequest('/system/resolveDataObjects', input_params, always_retry=always_retry, **kwargs)
|
def system_resolve_data_objects(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/resolveDataObjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/System-Methods#API-method:-/system/resolveDataObjects
| 3.631024
| 5.007755
| 0.72508
|
return DXHTTPRequest('/system/findExecutions', input_params, always_retry=always_retry, **kwargs)
|
def system_find_executions(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findExecutions API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindExecutions
| 3.485262
| 4.610849
| 0.755883
|
return DXHTTPRequest('/system/findAnalyses', input_params, always_retry=always_retry, **kwargs)
|
def system_find_analyses(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findAnalyses API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindAnalyses
| 3.954512
| 5.015233
| 0.7885
|
return DXHTTPRequest('/system/findDatabases', input_params, always_retry=always_retry, **kwargs)
|
def system_find_databases(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findDatabases API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindDatabases
| 3.816944
| 5.700819
| 0.669543
|
return DXHTTPRequest('/system/findJobs', input_params, always_retry=always_retry, **kwargs)
|
def system_find_jobs(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findJobs API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindJobs
| 3.961932
| 5.104447
| 0.776173
|
return DXHTTPRequest('/system/findProjects', input_params, always_retry=always_retry, **kwargs)
|
def system_find_projects(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findProjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindProjects
| 3.695713
| 5.335766
| 0.69263
|
return DXHTTPRequest('/system/findUsers', input_params, always_retry=always_retry, **kwargs)
|
def system_find_users(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findUsers API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method%3A-%2Fsystem%2FfindUsers
| 3.731944
| 5.435518
| 0.686585
|
return DXHTTPRequest('/system/findProjectMembers', input_params, always_retry=always_retry, **kwargs)
|
def system_find_project_members(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findProjectMembers API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method:-/system/findProjectMembers
| 3.42285
| 4.837612
| 0.70755
|
return DXHTTPRequest('/system/findOrgs', input_params, always_retry=always_retry, **kwargs)
|
def system_find_orgs(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/findOrgs API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method:-/system/findOrgs
| 3.558672
| 4.556001
| 0.781096
|
return DXHTTPRequest('/system/generateBatchInputs', input_params, always_retry=always_retry, **kwargs)
|
def system_generate_batch_inputs(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/generateBatchInputs API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method:-/system/generateBatchInputs
| 4.122595
| 4.622102
| 0.891931
|
return DXHTTPRequest('/system/globalSearch', input_params, always_retry=always_retry, **kwargs)
|
def system_global_search(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/globalSearch API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Search#API-method:-/system/globalSearch
| 3.872365
| 5.521649
| 0.701306
|
return DXHTTPRequest('/system/greet', input_params, always_retry=always_retry, **kwargs)
|
def system_greet(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/greet API method.
| 4.411052
| 3.749522
| 1.17643
|
return DXHTTPRequest('/system/headers', input_params, always_retry=always_retry, **kwargs)
|
def system_headers(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/headers API method.
| 3.643879
| 3.843071
| 0.948169
|
return DXHTTPRequest('/system/shortenURL', input_params, always_retry=always_retry, **kwargs)
|
def system_shorten_url(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/shortenURL API method.
| 3.678652
| 3.535676
| 1.040438
|
return DXHTTPRequest('/system/whoami', input_params, always_retry=always_retry, **kwargs)
|
def system_whoami(input_params={}, always_retry=True, **kwargs)
|
Invokes the /system/whoami API method.
| 3.435854
| 3.799717
| 0.904239
|
return DXHTTPRequest('/%s/describe' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def user_describe(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /user-xxxx/describe API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Users#API-method%3A-%2Fuser-xxxx%2Fdescribe
| 3.063274
| 3.892719
| 0.786924
|
return DXHTTPRequest('/%s/update' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def user_update(object_id, input_params={}, always_retry=False, **kwargs)
|
Invokes the /user-xxxx/update API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Users#API-method%3A-%2Fuser-xxxx%2Fupdate
| 3.581838
| 4.298423
| 0.833291
|
return DXHTTPRequest('/%s/addStage' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_add_stage(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/addStage API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FaddStage
| 3.609261
| 4.232947
| 0.852659
|
return DXHTTPRequest('/%s/addTags' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_add_tags(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/addTags API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FaddTags
| 3.273696
| 3.843825
| 0.851677
|
return DXHTTPRequest('/%s/addTypes' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_add_types(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/addTypes API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Types#API-method%3A-%2Fclass-xxxx%2FaddTypes
| 3.339802
| 3.881081
| 0.860534
|
return DXHTTPRequest('/%s/close' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_close(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/close API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Data-Object-Lifecycle#API-method%3A-%2Fclass-xxxx%2Fclose
| 3.329723
| 4.315219
| 0.771623
|
return DXHTTPRequest('/%s/describe' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_describe(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/describe API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2Fdescribe
| 3.438823
| 3.860735
| 0.890717
|
return DXHTTPRequest('/%s/dryRun' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_dry_run(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/dryRun API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FdryRun
| 3.835841
| 3.796051
| 1.010482
|
return DXHTTPRequest('/%s/getDetails' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_get_details(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/getDetails API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Details-and-Links#API-method%3A-%2Fclass-xxxx%2FgetDetails
| 3.635269
| 3.720739
| 0.977029
|
return DXHTTPRequest('/%s/isStageCompatible' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_is_stage_compatible(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/isStageCompatible API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FisStageCompatible
| 3.750827
| 3.637201
| 1.03124
|
return DXHTTPRequest('/%s/listProjects' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_list_projects(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/listProjects API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Cloning#API-method%3A-%2Fclass-xxxx%2FlistProjects
| 3.435024
| 4.095092
| 0.838815
|
return DXHTTPRequest('/%s/moveStage' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_move_stage(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/moveStage API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FmoveStage
| 3.45614
| 4.384871
| 0.788197
|
return DXHTTPRequest('/%s/overwrite' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_overwrite(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/overwrite API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2Foverwrite
| 3.64633
| 4.393746
| 0.829891
|
return DXHTTPRequest('/%s/removeStage' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_remove_stage(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/removeStage API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FremoveStage
| 3.482835
| 4.240803
| 0.821268
|
return DXHTTPRequest('/%s/removeTags' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_remove_tags(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/removeTags API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Tags#API-method%3A-%2Fclass-xxxx%2FremoveTags
| 3.119026
| 3.908909
| 0.797928
|
return DXHTTPRequest('/%s/removeTypes' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_remove_types(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/removeTypes API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Types#API-method%3A-%2Fclass-xxxx%2FremoveTypes
| 3.209309
| 3.936772
| 0.815213
|
return DXHTTPRequest('/%s/rename' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_rename(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/rename API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Name#API-method%3A-%2Fclass-xxxx%2Frename
| 3.007368
| 3.94594
| 0.762142
|
return DXHTTPRequest('/%s/validateBatch' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_validate_batch(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/validateBatch API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FvalidateBatch
| 3.35405
| 3.964237
| 0.846077
|
return DXHTTPRequest('/%s/setDetails' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_set_details(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/setDetails API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Details-and-Links#API-method%3A-%2Fclass-xxxx%2FsetDetails
| 3.422015
| 3.566893
| 0.959383
|
return DXHTTPRequest('/%s/setProperties' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_set_properties(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/setProperties API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Properties#API-method%3A-%2Fclass-xxxx%2FsetProperties
| 3.163846
| 3.838928
| 0.824148
|
return DXHTTPRequest('/%s/setStageInputs' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_set_stage_inputs(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/setStageInputs API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FsetStageInputs
| 3.492741
| 3.898901
| 0.895827
|
return DXHTTPRequest('/%s/setVisibility' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_set_visibility(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/setVisibility API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Visibility#API-method%3A-%2Fclass-xxxx%2FsetVisibility
| 3.681696
| 4.165773
| 0.883797
|
return DXHTTPRequest('/%s/update' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_update(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/update API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2Fupdate
| 3.528178
| 4.61192
| 0.765013
|
return DXHTTPRequest('/%s/updateStageExecutable' % object_id, input_params, always_retry=always_retry, **kwargs)
|
def workflow_update_stage_executable(object_id, input_params={}, always_retry=True, **kwargs)
|
Invokes the /workflow-xxxx/updateStageExecutable API method.
For more info, see: https://wiki.dnanexus.com/API-Specification-v1.0.0/Workflows-and-Analyses#API-method%3A-%2Fworkflow-xxxx%2FupdateStageExecutable
| 3.500612
| 3.924764
| 0.891929
|
# If the image is already encoded in Base64, we have nothing to do here
if "src" not in img.attrs or img["src"].startswith("data:"):
return
elif re.match("https?://", img["src"]):
img_data = _load_url(img["src"]).read()
else:
img_data = _load_file(img["src"]).read()
img_type = imghdr.what("", img_data)
img_b64 = base64.b64encode(img_data)
src_data = "data:image/none;base64,"
if img_type:
src_data = "data:image/{};base64,{}".format(img_type, img_b64)
img["src"] = src_data
|
def _image_to_data(img)
|
Does the work of encoding an image into Base64
| 3.012202
| 2.790539
| 1.079434
|
if "href" in link.attrs and (re.search("\.css$", link["href"])) or ("rel" in link.attrs and link["rel"] is "stylesheet") or ("type" in link.attrs and link["type"] is "text/css"):
if re.match("https?://", link["href"]):
css_data = _load_url(link["href"]).read()
else:
css_data = _load_file(link["href"]).read()
link.clear()
if USING_PYTHON2:
link.string = css_data
else:
link.string = str(css_data)
link.name = "style"
del link["rel"]
del link["href"]
|
def _bake_css(link)
|
Takes a link element and turns it into an inline style link if applicable
| 2.745254
| 2.606675
| 1.053163
|
if "src" in script.attrs:
if re.match("https?://", script["src"]):
script_data = _load_url(script["src"]).read()
else:
script_data = _load_file(script["src"]).read()
script.clear()
if USING_PYTHON2:
script.string = "\n" + script_data + "\n"
else:
script.string = "\n" + str(script_data) + "\n"
del script["src"]
del script["type"]
|
def _bake_script(script)
|
Takes a script element and bakes it in only if it contains a remote resource
| 2.845523
| 2.636571
| 1.079251
|
if not os.path.exists(path):
parser.error("{} was not found!".format(path))
if USING_PYTHON2:
mode = "r"
else:
mode = "rb"
try:
f = open(path, mode)
return f
except IOError as ex:
parser.error("{path} could not be read due to an I/O error! ({ex})".format(path=path, ex=ex))
|
def _load_file(path)
|
Loads a file from the local filesystem
| 3.198411
| 3.073382
| 1.040681
|
try:
response = requests.get(url)
return BytesIO(response.content)
except IOError as ex:
parser.error("{url} could not be loaded remotely! ({ex})".format(url=url, ex=ex))
|
def _load_url(url)
|
Loads a URL resource from a remote server
| 4.228206
| 4.184722
| 1.010391
|
if len(soup.find_all("script")) == 0:
soup_str = soup.prettify(formatter=None).strip()
else:
soup_str = str(soup.html)
soup_str = re.sub("&", "&", soup_str)
soup_str = re.sub("<", "<", soup_str)
soup_str = re.sub(">", ">", soup_str)
return soup_str
|
def _get_bs4_string(soup)
|
Outputs a BeautifulSoup object as a string that should hopefully be minimally modified
| 2.152445
| 2.097747
| 1.026075
|
src = os.path.realpath(src)
path = os.path.dirname(src)
filename = os.path.basename(src)
html = _load_file(src).read()
if imghdr.what("", html):
html = "<html><body><img src='{}'/></body></html>".format(cgi.escape(filename))
# Change to the file's directory so image files with relative paths can be loaded correctly
cwd = os.getcwd()
os.chdir(path)
bs_html = bs4.BeautifulSoup(html, "html.parser")
images = bs_html.find_all("img")
for image in images:
_image_to_data(image)
for link in bs_html.find_all("link"):
_bake_css(link)
for script in bs_html.find_all("script"):
_bake_script(script)
os.chdir(cwd)
return bs_html
|
def bake(src)
|
Runs the encoder on the given source file
| 2.961593
| 3.009067
| 0.984223
|
[project, path, n] = parse_destination(destination)
try:
dxfile = dxpy.upload_string(html, media_type="text/html", project=project, folder=path, hidden=True, name=name or None)
return dxfile.get_id()
except dxpy.DXAPIError as ex:
parser.error("Could not upload HTML report to DNAnexus server! ({ex})".format(ex=ex))
|
def upload_html(destination, html, name=None)
|
Uploads the HTML to a file on the server
| 4.958365
| 4.998803
| 0.991911
|
[project, path, name] = parse_destination(destination)
files = [dxpy.dxlink(file_id) for file_id in file_ids]
details = {"files": files}
if width:
details["width"] = width
if height:
details["height"] = height
try:
dxrecord = dxpy.new_dxrecord(project=project, folder=path, types=["Report", "HTMLReport"], details=details, name=name)
dxrecord.close()
return dxrecord.get_id()
except dxpy.DXAPIError as ex:
parser.error("Could not create an HTML report record on DNAnexus servers! ({ex})".format(ex=ex))
|
def create_record(destination, file_ids, width=None, height=None)
|
Creates a master record for the HTML report; this doesn't contain contain the actual HTML, but reports
are required to be records rather than files and we can link more than one HTML file to a report
| 3.760163
| 3.556654
| 1.057219
|
try:
out_file = open(filename, "w")
out_file.write(html)
out_file.close()
except IOError as ex:
parser.error("Could not write baked HTML to local file {name}. ({ex})".format(name=filename, ex=ex))
|
def save(filename, html)
|
Creates a baked HTML file on the local system
| 3.722192
| 3.163002
| 1.176791
|
if size == 0:
magnitude = 0
level = 0
else:
magnitude = math.floor(math.log(size, 10))
level = int(min(math.floor(magnitude // 3), 4))
return ('%d' if level == 0 else '%.2f') % (float(size) / 2**(level*10)) + ' ' + SIZE_LEVEL[level]
|
def get_size_str(size)
|
Formats a byte size as a string.
The returned string is no more than 9 characters long.
| 4.0285
| 4.054832
| 0.993506
|
'''
:param thing: something that might be a job-based object reference hash
:param reftype: type that a job-based object reference would be (default is dict)
'''
return isinstance(thing, reftype) and \
((len(thing) == 2 and \
isinstance(thing.get('field'), basestring) and \
isinstance(thing.get('job'), basestring)) or \
(len(thing) == 1 and \
isinstance(thing.get('$dnanexus_link'), reftype) and \
isinstance(thing['$dnanexus_link'].get('field'), basestring) and \
isinstance(thing['$dnanexus_link'].get('job'), basestring)))
|
def is_job_ref(thing, reftype=dict)
|
:param thing: something that might be a job-based object reference hash
:param reftype: type that a job-based object reference would be (default is dict)
| 3.1061
| 2.163688
| 1.435558
|
'''
:param desc: The describe hash of a DNAnexus entity
:type desc: dict
Depending on the class of the entity, this method will print a
formatted and human-readable string containing the data in *desc*.
'''
if desc['class'] in ['project', 'workspace', 'container']:
print_project_desc(desc, verbose=verbose)
elif desc['class'] == 'app':
print_app_desc(desc, verbose=verbose)
elif desc['class'] == 'globalworkflow':
print_globalworkflow_desc(desc, verbose=verbose)
elif desc['class'] in ['job', 'analysis']:
print_execution_desc(desc)
elif desc['class'] == 'user':
print_user_desc(desc)
elif desc['class'] in ['org', 'team']:
print_generic_desc(desc)
else:
print_data_obj_desc(desc, verbose=verbose)
|
def print_desc(desc, verbose=False)
|
:param desc: The describe hash of a DNAnexus entity
:type desc: dict
Depending on the class of the entity, this method will print a
formatted and human-readable string containing the data in *desc*.
| 3.402907
| 2.063038
| 1.649464
|
# If you make this method consume an additional field, you must add it to
# get_ls_l_desc_fields above.
if 'state' in desc:
state_len = len(desc['state'])
if desc['state'] != 'closed':
state_str = YELLOW() + desc['state'] + ENDC()
else:
state_str = GREEN() + desc['state'] + ENDC()
else:
state_str = ''
state_len = 0
name_str = ''
if include_folder:
name_str += desc['folder'] + ('/' if desc['folder'] != '/' else '')
name_str += desc['name']
if desc['class'] in ['applet', 'workflow']:
name_str = BOLD() + GREEN() + name_str + ENDC()
size_str = ''
if 'size' in desc and desc['class'] == 'file':
size_str = get_size_str(desc['size'])
elif 'length' in desc:
size_str = str(desc['length']) + ' rows'
size_padding = ' ' * max(0, 9 - len(size_str))
return (state_str +
DELIMITER(' '*(8 - state_len)) + render_short_timestamp(desc['modified']) +
DELIMITER(' ') + size_str +
DELIMITER(size_padding + ' ') + name_str +
DELIMITER(' (') + ((desc['project'] + DELIMITER(':')) if include_project else '') + desc['id'] +
DELIMITER(')'))
|
def get_ls_l_desc(desc, include_folder=False, include_project=False)
|
desc must have at least all the fields given by get_ls_l_desc_fields.
| 3.453392
| 3.278782
| 1.053255
|
'''
:param desc: hash of execution's describe output
:param has_children: whether the execution has children to be printed
:param single_result: whether the execution is displayed as a single result or as part of an execution tree
:param is_cached_result: whether the execution should be formatted as a cached result
'''
is_not_subjob = desc['parentJob'] is None or desc['class'] == 'analysis' or single_result
result = ("* " if is_not_subjob and get_delimiter() is None else "")
canonical_execution_name = desc['executableName']
if desc['class'] == 'job':
canonical_execution_name += ":" + desc['function']
execution_name = desc.get('name', '<no name>')
# Format the name of the execution
if is_cached_result:
result += BOLD() + "[" + ENDC()
result += BOLD() + BLUE()
if desc['class'] == 'analysis':
result += UNDERLINE()
result += execution_name + ENDC()
if execution_name != canonical_execution_name and execution_name+":main" != canonical_execution_name:
result += ' (' + canonical_execution_name + ')'
if is_cached_result:
result += BOLD() + "]" + ENDC()
# Format state
result += DELIMITER(' (') + JOB_STATES(desc['state']) + DELIMITER(') ') + desc['id']
# Add unicode pipe to child if necessary
result += DELIMITER('\n' + (u'│ ' if is_not_subjob and has_children else (" " if is_not_subjob else "")))
result += desc['launchedBy'][5:] + DELIMITER(' ')
result += render_short_timestamp(desc['created'])
cached_and_runtime_strs = []
if is_cached_result:
cached_and_runtime_strs.append(YELLOW() + "cached" + ENDC())
if desc['class'] == 'job':
# Only print runtime if it ever started running
if desc.get('startedRunning'):
if desc['state'] in ['done', 'failed', 'terminated', 'waiting_on_output']:
runtime = datetime.timedelta(seconds=int(desc['stoppedRunning']-desc['startedRunning'])//1000)
cached_and_runtime_strs.append("runtime " + str(runtime))
elif desc['state'] == 'running':
seconds_running = max(int(time.time()-desc['startedRunning']//1000), 0)
msg = "running for {rt}".format(rt=datetime.timedelta(seconds=seconds_running))
cached_and_runtime_strs.append(msg)
if cached_and_runtime_strs:
result += " (" + ", ".join(cached_and_runtime_strs) + ")"
if show_outputs:
prefix = DELIMITER('\n' + (u'│ ' if is_not_subjob and has_children else (" " if is_not_subjob else "")))
if desc.get("output") != None:
result += job_output_to_str(desc['output'], prefix=prefix)
elif desc['state'] == 'failed' and 'failureReason' in desc:
result += prefix + BOLD() + desc['failureReason'] + ENDC() + ": " + fill(desc.get('failureMessage', ''),
subsequent_indent=prefix.lstrip('\n'))
return result
|
def get_find_executions_string(desc, has_children, single_result=False, show_outputs=True,
is_cached_result=False)
|
:param desc: hash of execution's describe output
:param has_children: whether the execution has children to be printed
:param single_result: whether the execution is displayed as a single result or as part of an execution tree
:param is_cached_result: whether the execution should be formatted as a cached result
| 3.792022
| 3.411508
| 1.111538
|
try:
if instance_count_arg is None:
return cls(None)
if isinstance(instance_count_arg, basestring) or isinstance(instance_count_arg, int):
return cls({entrypoint: {"clusterSpec": {"initialInstanceCount": int(instance_count_arg)}}})
if isinstance(instance_count_arg, dict):
return cls({k: {"clusterSpec": {"initialInstanceCount": int(v)}} for k, v in instance_count_arg.items()})
raise ValueError
except ValueError:
DXError('Expected instance_count field to be either an int, string or a dict')
|
def from_instance_count(cls, instance_count_arg, entrypoint="*")
|
Returns a SystemRequirementsDict that can be passed as a
"systemRequirements" input to job/new or run/ API calls.
The instance_count_arg should be either a:
* string or int eg. "6" or 8
* dictionary, eg. {"main": 4, "other_function": 2}
| 2.932437
| 2.737191
| 1.071331
|
if instance_type_arg is None:
return cls(None)
if isinstance(instance_type_arg, basestring):
# By default, all entry points ("*") should use this instance type
return cls({entrypoint: {"instanceType": instance_type_arg}})
if isinstance(instance_type_arg, dict):
# instance_type is a map of entry point to instance type
return cls({fn: {"instanceType": fn_inst} for fn, fn_inst in instance_type_arg.items()})
raise DXError('Expected instance_type field to be either a string or a dict')
|
def from_instance_type(cls, instance_type_arg, entrypoint="*")
|
Returns SystemRequirementsDict that can be passed as a
"systemRequirements" input to job/new or run/ API calls.
The instance_type_arg should be either a:
* string, eg. mem1_ssd1_x2
* dictionary, eg. {"main": "mem2_hdd2_x2", "other_function": "mem2_hdd2_x1"}
| 3.86225
| 3.702705
| 1.043089
|
if _type not in ('all', 'clusterSpec', 'instanceType'):
raise DXError("Expected '_type' to be either 'all', 'clusterSpec', or 'instanceType'")
if _type == 'all':
return cls(system_requirements)
extracted = defaultdict(dict)
for entrypoint, req in system_requirements.items():
if _type in req:
extracted[entrypoint][_type] = req[_type]
return cls(dict(extracted))
|
def from_sys_requirements(cls, system_requirements, _type='all')
|
Returns SystemRequirementsDict encapsulating system requirements.
It can extract only entrypoints with specific fields ('clusterSpec',
'instanceType', etc), depending on the value of _type.
| 3.74903
| 2.459376
| 1.524383
|
if d1 is None and d2 is None:
return None
d1 = d1 or {}
d2 = d2 or {}
added = {}
for key in set(list(d1.keys()) + list(d2.keys())):
added[key] = dict(d1.get(key, {}), **(d2.get(key, {})))
return added
|
def _add_dict_values(self, d1, d2)
|
Merges the values of two dictionaries, which are expected to be dictionaries, e.g
d1 = {'a': {'x': pqr}}
d2 = {'a': {'y': lmn}, 'b': {'y': rst}}
will return: {'a': {'x': pqr, 'y': lmn}, 'b': {'y': rst}}.
Collisions of the keys of the sub-dictionaries are not checked.
| 2.270057
| 2.089733
| 1.086291
|
'''
:rtype: :class:`DXRecord`
:param details: The contents of the record to be created.
:type details: dict
Additional optional parameters not listed: all those under
:func:`dxpy.bindings.DXDataObject.new`, except `details`.
Creates a new remote record object with project set to *project*
and returns the appropriate handler.
Example:
r = dxpy.new_dxrecord({"x": 1, "y": 2})
Note that this function is shorthand for::
dxrecord = DXRecord()
dxrecord.new(**kwargs)
'''
dxrecord = DXRecord()
dxrecord.new(details=details, **kwargs)
return dxrecord
|
def new_dxrecord(details=None, **kwargs)
|
:rtype: :class:`DXRecord`
:param details: The contents of the record to be created.
:type details: dict
Additional optional parameters not listed: all those under
:func:`dxpy.bindings.DXDataObject.new`, except `details`.
Creates a new remote record object with project set to *project*
and returns the appropriate handler.
Example:
r = dxpy.new_dxrecord({"x": 1, "y": 2})
Note that this function is shorthand for::
dxrecord = DXRecord()
dxrecord.new(**kwargs)
| 5.285036
| 1.457084
| 3.627133
|
if "init_from" in kwargs:
if kwargs["init_from"] is not None:
if not isinstance(kwargs["init_from"], DXRecord):
raise DXError("Expected instance of DXRecord to init_from")
dx_hash["initializeFrom"] = \
{"id": kwargs["init_from"].get_id(),
"project": kwargs["init_from"].get_proj_id()}
del kwargs["init_from"]
if close:
dx_hash["close"] = True
resp = dxpy.api.record_new(dx_hash, **kwargs)
self.set_ids(resp["id"], dx_hash["project"])
|
def _new(self, dx_hash, close=False, **kwargs)
|
:param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes.
:type dx_hash: dict
:param init_from: Record from which to initialize the metadata
:type init_from: :class:`DXRecord`
:param close: Whether or not to close the record immediately after creating it
:type close: boolean
Create a new remote record object.
| 3.17248
| 2.620682
| 1.210555
|
if isinstance(foo, dict):
for (key, val) in list(foo.items()):
if isinstance(val, dict):
_recursive_cleanup(val)
if val == "" or val == [] or val == {}:
del foo[key]
|
def _recursive_cleanup(foo)
|
Aggressively cleans up things that look empty.
| 2.293571
| 2.113652
| 1.085122
|
try:
old_cwd = os.getcwd()
os.chdir(destination_directory)
if isinstance(executable, dxpy.DXWorkflow):
_dump_workflow(executable, describe_output)
elif isinstance(executable, dxpy.DXGlobalWorkflow):
# Add inputs, outputs, stages. These fields contain region-specific values
# e.g. files or applets, that's why:
# * if the workflow is global, we will unpack the underlying workflow
# from the region of the current project context
# * if this is a regular, project-based workflow, we will just use
# its description (the describe_output that we already have)
# Underlying workflows are workflows stored in resource containers
# of the global workflow (one per each region the global workflow is
# enabled in). #TODO: add a link to documentation.
current_project = dxpy.WORKSPACE_ID
if not current_project:
raise DXError(
'A project needs to be selected to "dx get" a global workflow. You can use "dx select" to select a project')
region = dxpy.api.project_describe(current_project,
input_params={"fields": {"region": True}})["region"]
describe_output = executable.append_underlying_workflow_desc(describe_output, region)
_dump_workflow(executable, describe_output)
else:
_dump_app_or_applet(executable, omit_resources, describe_output)
except:
err_exit()
finally:
os.chdir(old_cwd)
|
def dump_executable(executable, destination_directory, omit_resources=False, describe_output={})
|
Reconstitutes an app, applet, or a workflow into a directory that would
create a functionally identical executable if "dx build" were run on it.
destination_directory will be the root source directory for the
executable.
:param executable: executable, i.e. app, applet, or workflow, to be dumped
:type executable: DXExecutable (either of: DXApp, DXApplet, DXWorkflow, DXGlobalWorkflow)
:param destination_directory: an existing, empty, and writable directory
:type destination_directory: str
:param omit_resources: if True, executable's resources will not be downloaded
:type omit_resources: boolean
:param describe_output: output of a describe API call on the executable
:type describe_output: dictionary
| 6.39874
| 5.887504
| 1.086834
|
if not isinstance(batchsize, int) or batchsize <= 0 or batchsize > 1000:
raise ValueError("batchsize for resolve_data_objects must be a positive integer not exceeding 1000")
args = {}
if project:
args.update({'project': project})
if folder:
args.update({'folder': folder})
results = []
# Call API method /system/resolveDataObjects in groups of size batchsize
for i in range(0, len(objects), batchsize):
args.update({'objects': objects[i:(i+batchsize)]})
results.extend(dxpy.api.system_resolve_data_objects(args)['results'])
return results
|
def resolve_data_objects(objects, project=None, folder=None, batchsize=1000)
|
:param objects: Data object specifications, each with fields "name"
(required), "folder", and "project"
:type objects: list of dictionaries
:param project: ID of project context; a data object's project defaults
to this if not specified for that object
:type project: string
:param folder: Folder path within the project; a data object's folder
path defaults to this if not specified for that object
:type folder: string
:param batchsize: Number of objects to resolve in each batch call to
system_resolve_data_objects; defaults to 1000 and is
only used for testing (must be a positive integer not
exceeding 1000)
:type batchsize: int
:returns: List of results parallel to input objects, where each
entry is a list containing 0 or more dicts, each corresponding
to a resolved object
:rtype: List of lists of dictionaries
Each returned element is a list of dictionaries with keys "project" and
"id". The number of dictionaries for each element may be 0, 1, or more.
| 2.96736
| 2.772943
| 1.070112
|
''' Takes an API method handler (dxpy.api.find*) and calls it with *query*,
and then wraps a generator around its output. Used by the methods below.
Note that this function may only be used for /system/find* methods.
'''
num_results = 0
if "limit" not in query:
query["limit"] = first_page_size
while True:
resp = api_method(query, **kwargs)
by_parent = resp.get('byParent')
descriptions = resp.get('describe')
def format_result(result):
if return_handler:
result = dxpy.get_handler(result['id'], project=result.get('project'))
if by_parent is not None:
return result, by_parent, descriptions
else:
return result
for i in resp["results"]:
if num_results == limit:
return
num_results += 1
yield format_result(i)
# set up next query
if resp["next"] is not None:
query["starting"] = resp["next"]
query["limit"] = min(query["limit"]*2, 1000)
else:
return
|
def _find(api_method, query, limit, return_handler, first_page_size, **kwargs)
|
Takes an API method handler (dxpy.api.find*) and calls it with *query*,
and then wraps a generator around its output. Used by the methods below.
Note that this function may only be used for /system/find* methods.
| 4.574163
| 2.706125
| 1.6903
|
return find_global_executables(dxpy.api.system_find_apps,
name=name, name_mode=name_mode, category=category,
all_versions=all_versions, published=published,
billed_to=billed_to, created_by=created_by, developer=developer,
created_after=created_after, created_before=created_before,
modified_after=modified_after, modified_before=modified_before,
describe=describe, limit=limit, return_handler=return_handler,
first_page_size=first_page_size, **kwargs)
|
def find_apps(name=None, name_mode='exact', category=None,
all_versions=None, published=None,
billed_to=None, created_by=None, developer=None,
created_after=None, created_before=None,
modified_after=None, modified_before=None,
describe=False, limit=None, return_handler=False, first_page_size=100, **kwargs)
|
This method is identical to :meth:`find_global_executables()` with the API method
used: :meth:`system_find_apps()`.
| 1.687725
| 1.523105
| 1.108082
|
return _find_one(find_data_objects, zero_ok=zero_ok, more_ok=more_ok, **kwargs)
|
def find_one_data_object(zero_ok=False, more_ok=True, **kwargs)
|
:param zero_ok:
If False (default), :class:`~dxpy.exceptions.DXSearchError` is
raised if the search has 0 results; if True, returns None if the
search has 0 results
:type zero_ok: bool
:param more_ok:
If False, :class:`~dxpy.exceptions.DXSearchError` is raised if
the search has 2 or more results
:type more_ok: bool
Returns one data object that satisfies the supplied constraints, or
None if none exist (provided *zero_ok* is True). Supports all search
constraint arguments supported by :meth:`find_data_objects()`.
| 2.702999
| 4.975706
| 0.543239
|
return _find_one(find_projects, zero_ok=zero_ok, more_ok=more_ok, **kwargs)
|
def find_one_project(zero_ok=False, more_ok=True, **kwargs)
|
:param zero_ok:
If False (default), :class:`~dxpy.exceptions.DXSearchError` is
raised if the search has 0 results; if True, returns None if the
search has 0 results
:type zero_ok: bool
:param more_ok:
If False, :class:`~dxpy.exceptions.DXSearchError` is raised if
the search has 2 or more results
:type more_ok: bool
Returns one project that satisfies the supplied constraints, or None
if none exist (provided *zero_ok* is True). Supports all search
constraint arguments supported by :meth:`find_projects()`.
| 2.778035
| 5.206185
| 0.533603
|
return _find_one(find_apps, zero_ok=zero_ok, more_ok=more_ok, **kwargs)
|
def find_one_app(zero_ok=False, more_ok=True, **kwargs)
|
:param zero_ok:
If False (default), :class:`~dxpy.exceptions.DXSearchError` is
raised if the search has 0 results; if True, returns None if the
search has 0 results
:type zero_ok: bool
:param more_ok:
If False, :class:`~dxpy.exceptions.DXSearchError` is raised if
the search has 2 or more results
:type more_ok: bool
Returns one app that satisfies the supplied constraints, or None if
none exist (provided *zero_ok* is True). Supports all search
constraint arguments supported by :meth:`find_apps()`.
| 2.747964
| 4.904448
| 0.5603
|
if "limit" not in query:
query["limit"] = min(first_page_size, 1000)
while True:
resp = api_method(org_id, query)
for result in resp["results"]:
yield result
# set up next query
if resp["next"] is not None:
query["starting"] = resp["next"]
query["limit"] = min(query["limit"] * 2, 1000)
else:
break
|
def _org_find(api_method, org_id, query, first_page_size=100)
|
Takes an API method handler ``dxpy.api.org_find...`` and calls it with
*org_id* and *query*, then wraps a generator around its output. Used by
:meth:`org_find_members` and :meth:`org_find_projects` below.
:param first_page_size: The number of results that the initial API call will return.
:type first_page_size: int
| 2.483693
| 2.966571
| 0.837227
|
query = {}
if level is not None:
query["level"] = level
query["describe"] = describe
return _org_find(dxpy.api.org_find_members, org_id, query)
|
def org_find_members(org_id=None, level=None, describe=False)
|
:param org_id: ID of the organization
:type org_id: string
:param level: The membership level in the org that each member in the result set must have (one of "MEMBER" or
"ADMIN")
:type level: string
:param describe: Whether or not to return the response of ``dxpy.api.user_describe`` for each result. False omits
the describe response; True includes it; a dict will be used as the input to ``dxpy.api.user_describe`` (to
customize the desired set of fields in the describe response).
:type describe: bool or dict
Returns a generator that yields all org members that match the query formed by intersecting all specified
constraints. The search is not restricted by any parameters that were unspecified.
| 4.318653
| 3.964571
| 1.089311
|
query = {}
if name is not None:
if name_mode == 'exact':
query['name'] = name
elif name_mode == 'glob':
query['name'] = {'glob': name}
elif name_mode == 'regexp':
query['name'] = {'regexp': name}
else:
raise DXError('org_find_projects: Unexpected value found for argument name_mode')
if ids is not None:
query["id"] = ids
if properties is not None:
if len(properties.keys()) == 1:
query["properties"] = properties
else:
query["properties"] = {"$and": [{k: v} for (k, v) in properties.iteritems()]}
if tags is not None:
if len(tags) == 1:
query["tags"] = tags[0]
else:
query["tags"] = {"$and": tags}
query["describe"] = describe
if public is not None:
query['public'] = public
if created_after is not None or created_before is not None:
query["created"] = {}
if created_after is not None:
query["created"]["after"] = dxpy.utils.normalize_time_input(created_after)
if created_before is not None:
query["created"]["before"] = dxpy.utils.normalize_time_input(created_before)
if region is not None:
query['region'] = region
if containsPHI is not None:
query["containsPHI"] = containsPHI
return _org_find(dxpy.api.org_find_projects, org_id, query)
|
def org_find_projects(org_id=None, name=None, name_mode='exact', ids=None, properties=None, tags=None, describe=False,
public=None, created_after=None, created_before=None, region=None, containsPHI=None)
|
:param org_id: ID of the organization
:type org_id: string
:param name: Name that each result must have (also see *name_mode* param)
:type name: string
:param name_mode: Method by which to interpret the *name* param ("exact": exact match,
"glob": use "*" and "?" as wildcards, "regexp": interpret as a regular expression)
:type name_mode: string
:param ids: List of project IDs. Each result must have a project ID that was specified in this list.
:type ids: array of strings
:param properties: Properties (key-value pairs) that each result must have
(use value True to require the property key and allow any value)
:type properties: dict
:param tags: Tags that each result must have
:type tags: list of strings
:param describe: Whether or not to return the response of ``dxpy.api.project_describe`` for each result. False
omits the describe response; True includes it; a dict will be used as the input to
``dxpy.api.project_describe`` (to customize the desired set of fields in the describe response).
:type describe: bool or dict
:param public: True indicates that each result must be public; False indicates that each result must be private;
None indicates that both public and private projects will be returned in the result set.
:type public: boolean or None
:param created_after: Timestamp after which each result was created
(see note accompanying :meth:`find_data_objects()` for interpretation)
:type created_after: int or string
:param created_before: Timestamp before which each result was created
(see note accompanying :meth:`find_data_objects()` for interpretation)
:type created_before: int or string
:param region: If specified, only returns projects where the project is in the given region.
:type region: string
:param containsPHI: If set to true, only returns projects that contain PHI.
If set to false, only returns projects that do not contain PHI.
:type containsPHI: boolean
:rtype: generator
Returns a generator that yields all projects that match the query formed by intersecting all specified
constraints. The search is not restricted by any parameters that were unspecified.
| 1.751187
| 1.688356
| 1.037214
|
return _find(dxpy.api.system_find_orgs, query, limit=None,
return_handler=False, first_page_size=first_page_size)
|
def find_orgs(query, first_page_size=10)
|
:param query: The input to the /system/findOrgs API method.
:type query: dict
:param first_page_size: The number of results that the initial
/system/findOrgs API call will return; default 10, max 1000. Subsequent
calls will raise the number of returned results exponentially up to a
max of 1000.
:type first_page_size: int
:rtype: generator
Returns a generator that yields all orgs matching the specified query. Will
transparently handle pagination as necessary.
| 6.568615
| 6.812107
| 0.964256
|
'''
Create a set of directories, so we could store the input files.
For example, seq1 could be stored under:
/in/seq1/NC_001122.fasta
TODO: this call could fail, we need to report a reasonable error code
Note that we create a directory for every file array, even if
it has zero inputs.
'''
# create the <idir> itself
file_load_utils.ensure_dir(idir)
# create each subdir
for d in dirs:
file_load_utils.ensure_dir(os.path.join(idir, d))
|
def _create_dirs(idir, dirs)
|
Create a set of directories, so we could store the input files.
For example, seq1 could be stored under:
/in/seq1/NC_001122.fasta
TODO: this call could fail, we need to report a reasonable error code
Note that we create a directory for every file array, even if
it has zero inputs.
| 9.986649
| 2.235705
| 4.466889
|
'''
Create a dict of values for the downloaded files. This is similar to the variables created
when running a bash app.
'''
file_key_descs, _ignore = file_load_utils.analyze_bash_vars(
file_load_utils.get_input_json_file(), None)
flattened_dict = {}
def add_if_no_collision(key, value, dict_):
if key not in dict_:
dict_[key] = value
for input_ in filtered_inputs:
if input_ not in file_key_descs:
continue
input_var_dict = file_key_descs[input_]
add_if_no_collision(input_ + '_path', input_var_dict["path"], flattened_dict)
add_if_no_collision(input_ + '_name', input_var_dict["basename"], flattened_dict)
add_if_no_collision(input_ + '_prefix', input_var_dict["prefix"], flattened_dict)
return flattened_dict
|
def _gen_helper_dict(filtered_inputs)
|
Create a dict of values for the downloaded files. This is similar to the variables created
when running a bash app.
| 3.960624
| 2.867342
| 1.381288
|
'''
Ensure at least ~1.2 GB memory per thread, see PTFM-18767
'''
return min(max_threads, num_cores, max(int(mem_available_mb/1200), 1))
|
def _get_num_parallel_threads(max_threads, num_cores, mem_available_mb)
|
Ensure at least ~1.2 GB memory per thread, see PTFM-18767
| 9.18889
| 2.557507
| 3.592909
|
paragraphs = string.split('\n\n')
refilled_paragraphs = [fill(paragraph) if not paragraph.startswith(ignored_prefix) else paragraph for paragraph in paragraphs]
return '\n\n'.join(refilled_paragraphs).strip('\n')
|
def refill_paragraphs(string, ignored_prefix=' ')
|
Refills the given text, where the text is composed of paragraphs
separated by blank lines (i.e. '\n\n'). Lines that begin with
ignored_prefix are not touched; this can be used to keep indented
code snippets from being incorrectly reformatted.
| 2.534758
| 2.557941
| 0.990937
|
if args.json:
print(json.dumps(list(results), indent=4))
elif args.brief:
for result in results:
print(result['id'])
else:
if args.func.__name__ in ("find_projects", "org_find_projects"):
_format_find_projects_results(results)
elif args.func.__name__ in ("org_find_members"):
_format_find_org_members_results(results)
elif args.func.__name__ in ("org_find_apps"): # should have "find_apps" here one day
_format_find_apps_results(results, verbose=args.verbose)
|
def format_find_results(args, results)
|
Formats the output of ``dx find ...`` commands for `--json` and `--brief` arguments; also formats if no formatting
arguments are given.
Currently used for ``dx find projects``, ``dx find org_projects``, ``dx find org_apps``,
and ``dx find org_members``
| 3.199214
| 2.868321
| 1.115361
|
draw_lines()
draw_histogram()
draw_bar_chart()
destination = "-r /report"
if use_html:
generate_html()
command = "dx-build-report-html {h} {d}".format(h=html_filename, d=destination)
else:
command = "dx-build-report-html {l} {b} {h} {d}".format(l=lines_filename, b=bars_filename, h=histogram_filename, d=destination)
sub_output = json.loads(subprocess.check_output(command, shell=True))
output = {}
output["report"] = dxpy.dxlink(sub_output["recordId"])
return output
|
def main(**kwargs)
|
Draw a couple of simple graphs and optionally generate an HTML file to upload them
| 5.329749
| 4.730925
| 1.126576
|
mu, sigma = 100, 15
x = mu + sigma * numpy.random.randn(10000)
fig = pyplot.figure()
ax = fig.add_subplot(111)
n, bins, patches = ax.hist(x, 50, normed=1, facecolor='green', alpha=0.75)
ax.set_xlabel('Random number generated')
ax.set_ylabel('Probability')
ax.set_xlim(40, 160)
ax.set_ylim(0, 0.03)
ax.grid(True)
pyplot.savefig(histogram_filename)
|
def draw_histogram()
|
Uses sample code from http://matplotlib.org/1.2.1/examples/api/histogram_demo.html
| 1.963489
| 1.841484
| 1.066253
|
N = 5
menMeans = (20, 35, 30, 35, 27)
menStd = (2, 3, 4, 1, 2)
ind = numpy.arange(N)
width = 0.35
fig = pyplot.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
womenMeans = (25, 32, 34, 20, 25)
womenStd = (3, 5, 2, 3, 3)
rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
ax.set_ylabel('Scores')
ax.set_title('Scores by group and color')
ax.set_xticks(ind+width)
ax.set_xticklabels(('G1', 'G2', 'G3', 'G4', 'G5'))
ax.legend((rects1[0], rects2[0]), ('Red', 'Yellow'))
def autolabel(rects):
for rect in rects:
height = rect.get_height()
ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d' % int(height),
ha='center', va='bottom')
autolabel(rects1)
autolabel(rects2)
pyplot.savefig(bars_filename)
|
def draw_bar_chart()
|
Uses sample code from http://matplotlib.org/1.2.1/examples/api/barchart_demo.html
| 1.429386
| 1.396799
| 1.02333
|
r = numpy.random.randn(200)
fig = pyplot.figure()
ax = fig.add_subplot(111)
ax.plot(r)
ax.grid(True)
pyplot.savefig(lines_filename)
|
def draw_lines()
|
Draws a line between a set of random values
| 4.117383
| 3.651327
| 1.12764
|
html_file = open(html_filename, "w")
html_file.write("<html><body>")
html_file.write("<h1>Here are some graphs for you!</h1>")
for image in [lines_filename, bars_filename, histogram_filename]:
html_file.write("<div><h2>{0}</h2><img src='{0}' /></div>".format(image))
html_file.write("</body></html>")
html_file.close()
|
def generate_html()
|
Generate an HTML file incorporating the images produced by this script
| 2.836811
| 2.714617
| 1.045013
|
def clean(s):
return u''.join([c if c in ASCII_PRINTABLE else '?' for c in s])
if USING_PYTHON2:
try:
return unicode(o)
except:
try:
s = str(o)
try:
return s.decode("utf-8")
except:
return clean(s[:2048]) + u" [Raw error message: " + unicode(s.encode("hex"), 'utf-8') + u"]"
except:
return u"(Unable to decode Python exception message)"
else:
return str(o)
|
def _safe_unicode(o)
|
Returns an equivalent unicode object, trying harder to avoid
dependencies on the Python default encoding.
| 4.888691
| 4.710323
| 1.037867
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.