Extending
LabKey Server Part 2:
Creating Applications
Adam Rauch
Partner, LabKey
Software
adam@labkey.com
Key extension mechanisms:
Custom queries
External schemas / data sources
Script reports
Server API / client libraries
File
-
based modules
Java modules
Retrieve & present data
Create applications
Extension Mechanisms
2
Terminology
Server API
An HTTP/JSON
-
based web services API
Provides direct, programmatic access to LabKey data and services from
most programming languages
Client Libraries
Provide Server API access from many popular languages: JavaScript,
Java, R, SAS, Perl, Python
Sometimes referred to as the “Client API”
3
SQL Server
Database
LabKey Database
Web Site
Query
Authentication
and Security
Data
Visualization
Study
Management
Collaboration
Assays
Flow
Cytometry
Proteomics
Server API
Client API
MySQL
Database
HTTP/HTML
HTTP/JSON
SAS Repository
4
LabKey API
Develop scripts and standalone applications that interact with
LabKey via the HTTP server API
Applications send and receive data over HTTP
Subject to security checks just like browser requests
Access the LabKey server API from any language that can handle
HTTP requests and JSON
Client libraries developed for popular languages:
JavaScript
R
Java
SAS
Perl
Python
LabKey API is stable and well documented
5
Authentication Using Credentials File
Standard CURL mechanism that keeps user names and
passwords (relatively) secure, out of code
R, Perl, and SAS libraries use
netrc
file for credentials
.
netrc
(Linux/Unix) or
_
netrc
(Windows) file in home directory
Python library uses file named
labkeycredentials.txt
Contents determine credentials to send with each request
Example
netrc
contents:
machine labkey.org
login adam@labkey.com
password
mypassword
6
JavaScript API
Most extensive client library; all other libraries are subsets,
patterned after JavaScript API
Designed for building interactive, data
-
driven web pages
Built on Ext JS application framework
Cross
-
browser JavaScript framework for rich web apps
Provides many UI widgets used throughout the product
LabKey API is free, but developing closed
-
source code to the Ext JS API
requires a
Sencha
license
JavaScript API understands current context:
Current folder
Currently logged in user
Server properties
Primarily an
asynchronous
API; uses callbacks extensively
7
JavaScript API Highlights
Query
Retrieve and modify data from any table or query (
selectRows
,
executeSql
,
insertRows
,
updateRows
,
deleteRows
)
Retrieve meta data about queries, views, schemas
Security
Retrieve information about users, groups, permissions
WebPart
: Render any
webpart
into a page
Ext.store
: Ext JS integration with UI elements
ActionURL
: Build standard LabKey URLs
Pipeline: Retrieve job status and start analyses
Utils
: Other useful methods
And much, much more…
8
JavaScript API Tips & Tricks
Results format: JavaScript objects and arrays
Authentication: automatically handled by browser
Documentation: LabKey Admin/Developer menu
Think
async
!
JavaScript debugging
Firebug
Chrome JavaScript Console
Use “Export to JavaScript” from any data grid
Wiki pages: great way to test and deploy code
9
R & Perl Client Libraries
Rlabkey
R Package
Functions: Query, Assay, context information
Results format: R data frames
Authentication:
netrc
file
Distribution: CRAN (standard R distribution network)
Documentation: CRAN, vignette included in package
Tip: Use “Export to R script” from any data grid
LabKey Perl Module
Functions: Query
Results format: hash reference
Authentication:
netrc
file
Distribution: CPAN (standard Perl distribution network)
Documentation: CPAN
10
Java & SAS Client Libraries
Java Client Library
Functions: Query, Assay, Security
Results format: Java maps and lists
Authentication: Credentials passed into methods
Distribution: LabKey download page
Documentation:
JavaDoc
in client library zip file
SAS Client Library
Functions: Query
Results format: SAS data sets
Authentication:
netrc
(or passed into macros)
Distribution: LabKey download page
Documentation: labkey.org
Tip: Use “Export to SAS script” from any data grid
11
Python Client Library
Brand new… so new, I haven’t tried it yet!
Functions: Query
Results format: Python dictionary
Authentication: labkeycredentials.txt file
Distribution: LabKey download page
Documentation: labkey.org
12
13
File
-
Based (aka “Simple”) Modules
Convenient mechanism for packaging and distributing code
Great for collaborative development (source code control)
and multi
-
server deployments (test, staging, production)
Can include:
HTML/JavaScript
pages and static resources
SQL scripts, custom queries, custom views,
s
chema
meta data
Assay definitions
Validation and transformation scripts
Reports
Folder types
No Java, no compile
Easy
dev
test
staging
production cycle
Tip: labkey.org tutorial and “Map
of Module
Content” topic
14
Java Modules
Can also extend LabKey via custom modules written in Java
Nearly all core modules are Java modules
Use MVC model based on Spring
Leverage massive internal API and large set
of third
-
party libraries
Pros
Most flexible and powerful way to extend LabKey
Cons
Require strong Java skills
Difficult to maintain when outside of the core team
Java server API is minimally documented and less stable
Your module(s) will likely require editing and recompiling with each new
LabKey release
Tip:
create_module
ant task builds a new module
15
Any questions?
Adam Rauch
adam@labkey.com
Enter the password to open this PDF file:
File name:
-
File size:
-
Title:
-
Author:
-
Subject:
-
Keywords:
-
Creation Date:
-
Modification Date:
-
Creator:
-
PDF Producer:
-
PDF Version:
-
Page Count:
-
Preparing document for printing…
0%
Σχόλια 0
Συνδεθείτε για να κοινοποιήσετε σχόλιο