In this scenario, you want to run an analysis job consisting solely of files which exist on your local machine. One way to do this would be to upload each file, then submit an analysis job with all of the file ids.
import requestsimport osLOCAL_FILES = [""] # Replace with your file paths, change list size as necessaryAPI_KEY =""# Replace with your api keyDESIRED_FOLDER =""# Replace with your desired folder namePIPELINE_ID =""# Replace with your pipeline idUPLOAD_URL ="https://app.biodock.ai/api/external/filesystem-items/upload-file"ANALYSIS_URL ="https://app.biodock.ai/api/external/analysis-jobs"# Upload filesbiodock_file_ids = []for my_file in LOCAL_FILES:withopen(my_file, "rb")as file_to_upload: data ={"fileName": os.path.basename(my_file),"destinationFolder": DESIRED_FOLDER} headers ={"X-API-KEY": API_KEY} files ={"upload": file_to_upload} response = requests.post(UPLOAD_URL, data=data, headers=headers, files=files)print(response.text) biodock_file_ids.append(response.json()["id"])# Submit analysis jobsubmit_headers ={"X-API-KEY": API_KEY,"Content-Type":"application/json"}data ={"filesystemIds": biodock_file_ids,"pipelineId": PIPELINE_ID}response = requests.post(ANALYSIS_URL, json=data, headers=submit_headers)print(response.text)
Upload and analyze files from your local machine and the Biodock Filesystem
In this scenario you have an existing folder with files on the Biodock Filesystem. You also have files on your local machine. You would like add the local files to the remote folder, and run analysis on all the files.
import requestsimport osLOCAL_FILES = [""] # Replace with your file paths, change list size as neccesaryAPI_KEY =""# Replace with your api keyBIODOCK_FOLDER_NAME =""# Replace with your existing folder nameBIODOCK_FOLDER_ID =""# Replace with your existing folder idPIPELINE_ID =""# Replace with your pipeline idUPLOAD_URL ="https://app.biodock.ai/api/external/filesystem-items/upload-file"ANALYSIS_URL ="https://app.biodock.ai/api/external/analysis-jobs"# Upload filesfor my_file in LOCAL_FILES:withopen(my_file, "rb")as file_to_upload: data ={"fileName": os.path.basename(my_file),"destinationFolder": BIODOCK_FOLDER_NAME} headers ={"X-API-KEY": API_KEY} files ={"upload": file_to_upload} response = requests.post(UPLOAD_URL, data=data, headers=headers, files=files)print(response.text)# Submit analysis job submit_headers ={"X-API-KEY": API_KEY,"Content-Type":"application/json"}data ={"filesystemIds": [BIODOCK_FOLDER_ID],"pipelineId": PIPELINE_ID}response = requests.post(ANALYSIS_URL, json=data, headers=headers)print(response.text)