Skip to content
Merged
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
4 changes: 4 additions & 0 deletions frontend/unified/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const SESSION_QUERY: TypedDocumentNode<
instrument {
name
}
startTime
}
}
}
Expand Down Expand Up @@ -299,6 +300,9 @@ export const App: React.FC = () => {
Technique[currentTechnique as keyof typeof Technique]
)}
visit={selectedVisit}
beamline={beamline}
startTime={session.startTime}
scanIds={selectedScanIds}
/>
</Stack>
<Stack spacing={VERTICAL_SPACING} width="500px">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { Button, Typography } from "@mui/material";
import { Option, Technique } from "../../types";
import { Beamline, Option, Technique } from "../../types";
import OptionSelect from "../OptionSelect";
import { CorSweepParameterConfiguration } from "./TomoParameterConfiguration";
import { PtyrexParameterConfiguration } from "./PtyrexParameterConfiguration";
import { ReactElement, useState } from "react";
import { LoaderProvider } from "../../../../tomography/src/contexts/LoaderContext";
import { SUBMIT_WORKFLOW_TEMPLATE } from "../../../../tomography/src/components/workflows/Submission";
import { useMutation } from "@apollo/client/react";
import { Visit } from "@diamondlightsource/sci-react-ui";
import { Visit, visitToText } from "@diamondlightsource/sci-react-ui";
import { InstrumentSession } from "../SessionSelector";

type ParameterConfigurationProps = {
technique: Technique;
template: string;
setTemplate: (_: string) => void;
availableTemplates: Option[];
visit: Visit;
beamline: Beamline;
startTime: InstrumentSession["startTime"];
scanIds: number[];
};

/**
Expand All @@ -28,16 +32,37 @@ type TemplateComponentMapping = {
};
};

// TODO: The filename part of this should come from the scan selector component
const HARDCODED_INPUT_FILEPATH =
"/dls/i12/data/2025/cm40628-3/rawdata/188700.nxs";
const DLS_FILESYSTEM_BEAMLINE_RAW_DATA_DIR_MAPPINGS = {
[Beamline.DIAD]: "nexus",
[Beamline["I08-1"]]: "nexus",
[Beamline.I12]: "rawdata",
[Beamline["I13-1"]]: "raw",
[Beamline["I13-2"]]: "raw",
[Beamline.I14]: "scan",
};

const determineBeamlineRawDataFilepath = (
beamline: Beamline,
year: string,
visit: Visit,
scanId: number
): string => {
const rawDataDirname =
DLS_FILESYSTEM_BEAMLINE_RAW_DATA_DIR_MAPPINGS[
beamline as keyof typeof DLS_FILESYSTEM_BEAMLINE_RAW_DATA_DIR_MAPPINGS
];
return `/dls/${beamline}/data/${year}/${visitToText(visit)}/${rawDataDirname}/${scanId}.nxs`;
};

export const ParameterConfiguration: React.FC<ParameterConfigurationProps> = ({
technique,
template,
setTemplate,
availableTemplates,
visit,
beamline,
startTime,
scanIds,
}: ParameterConfigurationProps) => {
const [templateParameters, setTemplateParameters] = useState<object>({});
const [resourceParameters] = useState({
Expand All @@ -47,12 +72,20 @@ export const ParameterConfiguration: React.FC<ParameterConfigurationProps> = ({

const [mutation] = useMutation(SUBMIT_WORKFLOW_TEMPLATE);

const sessionYear = new Date(startTime).getFullYear();
const rawDataFilepath = determineBeamlineRawDataFilepath(
beamline,
sessionYear,
visit,
scanIds[0]
);

const handleSubmitJob = () => {
// TODO: Validate parameters against JSON schema attached to the workflow template before
// sending the mutation
console.log("Submit job");
const parameters = {
input: HARDCODED_INPUT_FILEPATH,
input: rawDataFilepath,
...templateParameters,
...resourceParameters,
};
Expand Down
1 change: 1 addition & 0 deletions frontend/unified/src/components/SessionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const GET_SESSION_BY_REFERENCE: TypedDocumentNode<
proposalNumber
proposalCategory
}
startTime
}
}
`;
Expand Down
18 changes: 11 additions & 7 deletions frontend/unified/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ export enum Technique {
Xrd = "Xrd",
}

/**
* String representations of a beamline is how the beamline is represented in the DLS
* filesystem
*/
export enum Beamline {
DIAD,
"I08-1",
I12,
"I13-1",
"I13-2",
I14,
Epsic,
DIAD = "k11",
"I08-1" = "i08-1",
I12 = "i12",
"I13-1" = "i13-1",
"I13-2" = "i13-2",
I14 = "i14",
Epsic = "e01",
}

export type Option = { label: string; value: string; desc?: string };
Expand Down
Loading