vanvalenlab / deepcell-label

Cloud-based data annotation tools for biological images
https://label.deepcell.org
Other
73 stars 14 forks source link

Add API endpoint for creating projects from zip file #483

Closed ykevu closed 1 year ago

ykevu commented 1 year ago

Adds an API endpoint for creating projects with a zipfile opened in memory. This should make it easy to programmatically create DCL projects by simply sending a POST request to /api/project/zip with a field for 'zip' @rossbar !

I think this could probably be consolidated with the 'dropped' endpoint as well, but this is the simple and fast solution for now.

ykevu commented 1 year ago

@rossbar I realized that we can just use the dropped endpoint already; I guess I did something wrong when I tried it in the past. For instance, if we have a zip in local disk, we can just do:

import requests

url = '____/api/project/dropped'
axes = 'CZYX'
# Replace with the path to the local zipfile
zipfile_path = '___.zip'

with open(zipfile_path, 'rb') as f:
    files = {'images': f}
    data = {'axes': axes}
    response = requests.post(url, files=files, data=data)
    print(response.text)