{"id":21602920,"url":"https://github.com/dials/dials-rest","last_synced_at":"2025-03-18T13:36:47.436Z","repository":{"id":149673196,"uuid":"567313826","full_name":"dials/dials-rest","owner":"dials","description":"A RESTful API to a (limited) subset of DIALS functionality","archived":false,"fork":false,"pushed_at":"2023-06-29T09:26:38.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T18:36:53.343Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dials.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-17T14:27:19.000Z","updated_at":"2023-01-23T10:51:44.000Z","dependencies_parsed_at":"2024-11-24T19:14:44.873Z","dependency_job_id":"574c29a8-7038-43be-8111-47efa9bb1c21","html_url":"https://github.com/dials/dials-rest","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dials%2Fdials-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dials%2Fdials-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dials%2Fdials-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dials%2Fdials-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dials","download_url":"https://codeload.github.com/dials/dials-rest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244232384,"owners_count":20420089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T19:14:40.837Z","updated_at":"2025-03-18T13:36:47.411Z","avatar_url":"https://github.com/dials.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A RESTful API to a (limited) subset of DIALS functionality.\n\n```\nmamba env create -f environment.yml\nmamba activate dials-rest\npip install -e .\n```\n\nGenerate a JWT secret and store it in the `DIALS_REST_JWT_SECRET` environment variable:\n```\n$ export DIALS_REST_JWT_SECRET=`openssl rand -hex 32`\n```\n\nCreate a new access token:\n```\n$ export TOKEN=`create-access-token --expiry 2023-06-01`\n```\n\nStart the app:\n```\n$ uvicorn dials_rest.main:app --reload\n```\n\n\u003c!-- curl -X 'POST' 'http://127.0.0.1:8001/export_bitmap/' -H 'accept: application/json' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODU1Nzc2MDB9.i6ipplAzjhfBDAZFRsw3UTXYWbQnzZ02YDUSnpvz4j0' -H 'Content-Type: application/json' -d '{ --\u003e\nIn another terminal:\n```\ncurl -X 'POST' 'http://127.0.0.1:8000/export_bitmap/' -H 'accept: application/json' -H \"Authorization: Bearer $TOKEN\" -H 'Content-Type: application/json' -d '{\n  \"filename\": \"/dls/i24/data/2022/cm31109-5/myoglobin_dithionite/myglobin_3_00001.cbf\",\n  \"image_index\": 1,\n  \"format\": \"png\",\n  \"binning\": 4,\n  \"display\": \"image\",\n  \"colour_scheme\": \"greyscale\",\n  \"brightness\": 10,\n  \"resolution_rings\": {\n    \"show\": true,\n    \"number\": 10\n  }\n}' -o image.png\n```\n\n\n## Docker/podman\nTo build with docker/podman:\n```\n$ podman build -t dials-rest --format=docker .\n```\n\nTo create an access token:\n```\n$ podman run -e DIALS_REST_JWT_SECRET=$DIALS_REST_JWT_SECRET -it dials-rest /env/bin/create-access-token\n```\n\nTo run the server:\n```\n$ podman run -e DIALS_REST_JWT_SECRET=$DIALS_REST_JWT_SECRET -p 127.0.0.1:8081:80 dials-rest\n```\n\n\n## Monitoring\nBefore starting the DIALS REST server export the environment variable `export DIALS_REST_ENABLE_METRICS=1` to enable a `/metrics` endpoint in [prometheus](https://prometheus.io/) format.\n\nNext add a simple `prometheus.yml` config file that tells prometheus where to scrape metrics from:\n```\n$ cat \u003e prometheus.yaml \u003c\u003c EOF\nscrape_configs:\n  - job_name: \"dials-rest\"\n    scrape_interval: 15s\n    static_configs:\n      - targets: [\"localhost:8000\"]\nEOF\n```\nRun prometheus via podman (or equivalently docker) exposed on port 9091:\n```\n$ podman run --network=host -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --web.listen-address=\"localhost:9091\" --config.file=/etc/prometheus/prometheus.yml\n```\n\n\n## Unit tests\nTo run unit tests:\n```\n$ mamba install -y dials-data httpx pytest\n$ pytest --regression\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdials%2Fdials-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdials%2Fdials-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdials%2Fdials-rest/lists"}