def get_report_api_wrapper(): global __api_wrapper, __report_config if __api_wrapper is None: __report_config_init() __api_wrapper = APIWrapper(__report_config['domain'], __report_config['containerPath'], __report_config['contextPath'], __report_config['useSsl'], api_key=__api_key) return __api_wrapper
def __init__(self): with open("../config/keys.json", "r") as file: config = json.load(file) self.labkey_server = "https://immunespace.org" self.project_name = "Studies" # Studies # container_path self.context_path = "study" # study ? self.api_key = config.get("apiKey", False) if not self.api_key: raise Exception self.api = APIWrapper(self.labkey_server, self.project_name, self.context_path, self.api_key)
def api(server_context_vars): server, context_path = server_context_vars api = APIWrapper(server, PROJECT_NAME, context_path, use_ssl=False) api.security.stop_impersonating( ) # Call stop impersonating incase previous test run failed while impersonating a user. return api
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from labkey.api_wrapper import APIWrapper from labkey.experiment import Batch, Run labkey_server = "localhost:8080" project_name = "ModulesAssayTest" # Project folder name context_path = "labkey" api = APIWrapper(labkey_server, project_name, context_path, use_ssl=False) assay_id = 3315 # provide one from your server ################### # Save an Assay batch ################### # Generate the Run object(s) run_test = Run() run_test.name = "python upload" run_test.data_rows = [ { # ColumnName: Value "SampleId": "Monkey 1", "TimePoint": "2008/11/02 11:22:33",
from labkey.exceptions import ( RequestError, QueryNotFoundError, ServerContextError, ServerNotFoundError, ) from labkey.query import Pagination, QueryFilter from requests.exceptions import Timeout import copy print("Create a server context") labkey_server = "localhost:8080" project_name = "ModuleAssayTest" # Project folder name context_path = "labkey" api = APIWrapper(labkey_server, project_name, context_path, use_ssl=False) schema = "lists" table = "Demographics" column1 = "Group Assignment" column2 = "Participant ID" ################### # Test basic select_rows ################### result = api.query.select_rows(schema, table) if result is not None: print(result["rows"][0]) print("select_rows: There are " + str(result["rowCount"]) + " rows.") else:
import os import subprocess import argparse import labkey as lk import pandas as pd from labkey.api_wrapper import APIWrapper import glob as glob key_file = '/global/cfs/cdirs/metatlas/labkey_user.txt' with open(key_file,'r') as fid: api_key = fid.read().strip() labkey_server='metatlas.nersc.gov' project_name='LIMS/' api = APIWrapper(labkey_server, project_name, use_ssl=True,api_key=api_key) def get_tasks_from_lims(): sql = """SELECT input_file,output_file FROM file_conversion_task WHERE task='raw_to_mzml';""" # context_path = "labkey" sql_result = api.query.execute_sql('lists', sql,max_rows=1e6) if sql_result is None: print(('execute_sql: Failed to load results from ' + schema + '.' + table)) return None else: df = pd.DataFrame(sql_result['rows']) df = df[[c for c in df.columns if not c.startswith('_')]] return df