- install uv using these instructions here.
- In the
\maskfolder, runuv venv,uv sync, andsource .venv/bin/activate - cd into
backendfolder - run
python manage.py migrateandpython manage.py runserver
Then, the API should be up and running. I like to use Postman to interact with the API though any method should work. Note that anytime you're uploading a file, you should upload it using form-data with the key, "file".
To send a POST request with a file through Postman, go to Body -> form-data -> add a key named "file" and switch the type to file.
Then upload your file. Next, go to headers and add a new header named "Content-Disposition" with the value form-data; name="file"; filename="your_file_name_here"
To get less warnings in vscode using the venv, do which python to get interpreter path.
- Upload instrument config
- Create Project
- Upload Image
- Upload Objects
- Generate Mask
run pytest
curl {PROTOCOL} "{URL}"\
-H "Content-Type: application/json" \
-H "user-id: my_user" \ -d '{"json_obj":"here"}'
- PROTOCOL = GET, POST, etc
- URL = "BASE_URL/api/project/create/" etc
- replace user-id value with your email
- if you're sending an .obj or .csv file, replace Content-Type with "text/plain" and "application/csv" respectively.
If you're ever unclear as to what a curl command for an endpoint should look like, send the description or this file to an LLM and ask it to generate a curl command for that endpoint.
curl -X POST http://127.0.0.1:8000/api/images/uploadimg/ \ -H "user-id: user@gmail.com" \ -F "project_name=proj1" \ -F "image=/path/to/image/file"
curl -X POST http://127.0.0.1:8000/api/objects/upload/ \ -H "user-id: my_user" \ -F "file=/path/to/obj/file" \ -F "list_name=my_objects"
curl -X POST http://127.0.0.1:8000/api/masks/generate/ \
-H "Content-Type: application/json" \
-H "user-id: my_user" \
-d '{"filename": "mask001", "objects": {"list_name": "my_objects"}, "instrument": "IMACS"}'
See a full example of what to include in an instrument setup json
Almost all endpoints require a user-id header
- Projects group images, masks, and an (optional) associated object list.
- Body: project_name (string), center_ra (string/number), center_dec (string/number)
- Retrieve high‑level project info: listed image names and mask names.
- Retrieve a list of project associated with the user-id sent in headers
- Upload a file (.obj or JSON) to create a new object list for a user.
- Request data: file, user_id, list_name
- Returns IDs of created objects and the list name.
- Retrieve the object lists and the objects it contains.
- Retrieve a list of all object lists associated with the user-id sent in headers
- delete object list
- delete object
- Retrieve mask details by mask name. Includes status, instrument version, setup, object lists, excluded objects, and features.
- Generate a mask from provided data.
- Request JSON body should include filename, objects (either a list of object IDs or an object list name), and instrument setup.
- See a full example of what to include in an instrument setup json
- Returns path to the generated .SMF file if successful.
- Mark a mask as COMPLETED (used by technicians to indicate a mask has been cut).
- Mark a mask as FINALIZED (required before machine code generation).
- Mark a mask as DRAFT (used to return a mask for further revision by technicians).
- Get a list of all finalized masks in the database
- Get a list of all completed masks in the database
- Generate the machine code, mask must be marked as COMPLETED
- Form Data: project_name (string), mask_name (string), overwrite (bool if you want to rewrite existing code)
- Get the generated machine code
- Retrieve instrument configuration by instrument name.
- Optional query param version returns a specific version; otherwise returns latest.
- Upload a new instrument configuration.
- Stores instrument, filters, dispersers, and auxillary info
- Automatically inputs version if existing configs found.
- Return the image file (content-type image/jpeg).
- Form fields: project_name (string), image (file upload)