Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ venv*
.vscode
*.egg-info/
__pycache__/
build/
build/
static/
22 changes: 14 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@

# This file is for use as a devcontainer and a runtime container
#
# The devcontainer should use the build target and run as root with podman
# or docker with user namespaces.
#

# Build static UI
FROM node:20 AS ui-build
WORKDIR /workspace/calibration_ui
COPY calibration_ui/ .
RUN npm install
RUN npm run build

FROM python:3.10 AS build

# Create working directory
Expand All @@ -16,17 +25,14 @@ ENV PATH=/venv/bin:$PATH
RUN pip install --upgrade pip
RUN pip install .[dev]


# Add apt-get system dependencies for runtime here if needed
# RUN apt-get update && apt-get upgrade -y && \
# apt-get install -y --no-install-recommends \
# desired-packages \
# && rm -rf /var/lib/apt/lists/*

RUN apt-get update
RUN apt-get install libgl1 -y
RUN apt-get install libglx-mesa0 -y

# ENTRYPOINT ["uvicorn", "main:app", "--host", "172.23.169.93", "--port", "8000"]
COPY --from=ui-build /workspace/calibration_ui/dist ./static

ENV SERVE_UI=True

ENTRYPOINT ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

EXPOSE 8000
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,46 @@ Service Workflow:
6. Identify state of positions ["None", "Puck", "Lid"]
7. Return FastAPI response - ["result"], ["position"], ["image"]

Documentation:
## Testing Locally

To set up your dev environment, from the top directory:

```
module load python/3.11
python -m venv .venv
source .venv/bin/activate
pip install -e .

cd calibration_ui
module load node/latest
npm install
```

To test locally you need to run

```
export USE_MOCKED_DATA=True
uvicorn main:app --reload
```

in one terminal then:

```
cd calibration_ui
npm run dev
```

Then navigate to the URL that is given to you from VITE.

Alternatively you can run the pod locally with:

```
podman build -t i15j-rcs .
podman run -p 8000:8000 -e USE_MOCKED_DATA=true i15j-rcs:latest
```

and navigate to http://127.0.0.1:8000/.

## Older Documentation:
User Guide: https://confluence.diamond.ac.uk/display/SSCC/Documentation%3A+User+Guide
Developer Guide: https://confluence.diamond.ac.uk/display/SSCC/Documentation%3A+Developer%27s+Guide
24 changes: 24 additions & 0 deletions calibration_ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
23 changes: 23 additions & 0 deletions calibration_ui/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])
13 changes: 13 additions & 0 deletions calibration_ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>calibration_ui</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
Loading
Loading