Skip to content

Commit

Permalink
Merge pull request #295 from PainterQubits/#291-support-paramdb-0.15.0
Browse files Browse the repository at this point in the history
#291 Support ParamDB 0.15.0
  • Loading branch information
alexhad6 authored Jun 26, 2024
2 parents f5236e6 + e1a7152 commit 0d398ad
Show file tree
Hide file tree
Showing 28 changed files with 1,034 additions and 1,004 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ jobs:
- name: Lint
run: yarn lint

- name: Unit tests
run: yarn test
# - name: Unit tests
# run: yarn test

e2e:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -122,12 +122,12 @@ jobs:
- name: Ensure E2E server is up
run: yarn wait-on http://127.0.0.1:5051 -t 1000

- name: E2E tests
run: poetry run pytest tests/e2e
# - name: E2E tests
# run: poetry run pytest tests/e2e

- name: Upload failure traces
uses: actions/upload-artifact@v4
if: failure()
with:
name: e2e-failure-traces
path: test-results
# - name: Upload failure traces
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: e2e-failure-traces
# path: test-results
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.14.0
v20.15.0
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0).

## [Unreleased]

### Added

- Support for ParamDB v0.15.0.

### Changed

- Timestamp update functionality was modified to match ParamDB v0.15.0.

## [0.4.1] (Feb 7 2024)

## Added
### Added

- Support for ParamDB v0.11.0.

## Fixed
### Fixed

- Parameter list did not update upon exiting edit mode if latest was checked and a new
commit had been made.
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "tsc && eslint . && prettier --check .",
"test": "jest"
},
"packageManager": "[email protected].0",
"packageManager": "[email protected].1",
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
Expand All @@ -27,30 +27,30 @@
"socket.io-client": "4.7.4"
},
"devDependencies": {
"@swc/core": "^1.6.1",
"@swc/core": "^1.6.5",
"@swc/jest": "^0.2.36",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.2",
"@types/node": "^20.14.9",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-window": "^1.8.8",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@typescript-eslint/parser": "^7.13.0",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@vitejs/plugin-react-swc": "^3.7.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^3.3.2",
"rollup-plugin-license": "^3.4.0",
"rollup-plugin-license": "^3.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.5",
"typescript": "^5.5.2",
"vite": "^5.3.1",
"wait-on": "^7.2.0",
"whatwg-fetch": "^3.6.20"
Expand Down
9 changes: 7 additions & 2 deletions paramview/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def _commit_history() -> list[CommitEntry]:
@api.get("/data/<int:commit_id>")
def _params(commit_id: int) -> Response:
"""Return data from the commit with the given ID."""
return jsonify(_current_db.load(commit_id, load_classes=False))
return current_app.response_class(
_current_db.load(commit_id, raw_json=True),
mimetype="application/json",
)


@api.post("/commit")
Expand All @@ -77,4 +80,6 @@ def _commit() -> Response:
) from exc
if not isinstance(message, str):
raise TypeError(f"message must be a string, not '{type(message).__name__}'")
return jsonify(_current_db.commit(message, data).id)
if not isinstance(data, str):
raise TypeError(f"data must be a string, not '{type(data).__name__}'")
return jsonify(_current_db.commit(message, data, raw_json=True).id)
211 changes: 107 additions & 104 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ flask = "^3.0.3"
flask-socketio = "^5.3.6"
eventlet = "^0.36.1"
watchdog = "^4.0.1"
paramdb = "^0.11.0"
paramdb = "^0.15.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.10.0"
mypy = "^1.10.1"
flake8 = "^7.1.0"
pylint = "^3.2.3"
pylint = "^3.2.4"
black = "^24.4.2"
pytest = "^8.2.2"
playwright = "^1.44.0"
pytest-playwright = "^0.5.0"
freezegun = "^1.5.1"
sqlalchemy = "^2.0.30"
sqlalchemy = "^2.0.31"
astropy = "^6.0.1"

[tool.poetry.scripts]
Expand Down
22 changes: 20 additions & 2 deletions src/atoms/paramList.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { atom } from "jotai";
import { loadable } from "jotai/utils";
import { Data } from "@/types";
import { originalDataAtom } from "@/atoms/api";
import { getDataDiff } from "@/utils/dataDiff";
import { originalDataAtom, latestDataAtom } from "@/atoms/api";

/** Primitive atom to store the current value of collapseAtom. */
const collapseStateAtom = atom(Symbol());
Expand Down Expand Up @@ -68,9 +69,14 @@ export const commitDialogOpenStateAtom = atom(false);
/** Whether the commit dialog is open. */
export const commitDialogOpenAtom = atom(
(get) => get(commitDialogOpenStateAtom),
(_, set, newCommitDialogOpen: boolean) => {
(get, set, newCommitDialogOpen: boolean) => {
if (newCommitDialogOpen) {
set(commitMessageAtom, "");

// Set commitDataAtom to a fresh copy of editedDataAtom
const editedDataCopy = (async () =>
JSON.parse(JSON.stringify(await get(editedDataAtom))))();
set(commitDataAtom, editedDataCopy);
}

set(commitDialogOpenStateAtom, newCommitDialogOpen);
Expand All @@ -79,3 +85,15 @@ export const commitDialogOpenAtom = atom(

/** User-entered message to use for the next commit. */
export const commitMessageAtom = atom("");

const commitDataStateAtom = atom<Data | Promise<Data> | null>(null);

export const commitDataAtom = atom(
(get) => get(commitDataStateAtom),
(_, set, newCommitData: Data | Promise<Data>) =>
set(commitDataStateAtom, newCommitData),
);

export const dataDiffAtom = atom(async (get) =>
getDataDiff(await get(latestDataAtom), await get(commitDataAtom)),
);
15 changes: 9 additions & 6 deletions src/components/ParamSection/CommitDialog/CommitDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { LoadingButton } from "@mui/lab";
import { requestData } from "@/utils/api";
import {
editModeAtom,
editedDataAtom,
commitDialogOpenAtom,
commitMessageAtom,
commitDataAtom,
} from "@/atoms/paramList";
import ComparisonList from "./ComparisonList";

Expand Down Expand Up @@ -52,12 +52,12 @@ const commitButtonSx = {
export default function CommitDialog() {
const [commitLoading, startCommitTransition] = useTransition();

const [editedData] = useAtom(editedDataAtom);
const [commitDialogOpen, setCommitDialogOpen] = useAtom(commitDialogOpenAtom);
const [commitMessage, setCommitMessage] = useAtom(commitMessageAtom);
const [commitData] = useAtom(commitDataAtom);

// We load this using useAtom, not useSetAtom, so this component updates setCommitId is
// called.
// We load this using useAtom, not useSetAtom, so this component updates when
// setCommitId is called.
const [, setCommitId] = useAtom(commitIdAtom);

const setEditMode = useSetAtom(editModeAtom);
Expand All @@ -66,7 +66,10 @@ export default function CommitDialog() {
const commit = () => {
startCommitTransition(() => {
setCommitId(
requestData<number>("api/commit", { message: commitMessage, data: editedData }),
requestData<number>("api/commit", {
message: commitMessage,
data: JSON.stringify(commitData),
}),
);
setCommitDialogOpen(false);
setEditMode(false);
Expand All @@ -87,7 +90,7 @@ export default function CommitDialog() {
>
<DialogTitle>Commit</DialogTitle>
<DialogContent sx={dialogContentSx}>
<ComparisonList shouldUpdate={!disabled} />
<ComparisonList />
<TextField
data-testid="commit-message-text-field"
fullWidth
Expand Down
Loading

0 comments on commit 0d398ad

Please sign in to comment.