diff --git a/frontend/unified/src/App.tsx b/frontend/unified/src/App.tsx index fa35407..015dc09 100644 --- a/frontend/unified/src/App.tsx +++ b/frontend/unified/src/App.tsx @@ -76,6 +76,7 @@ export const SESSION_QUERY: TypedDocumentNode< instrument { name } + startTime } } } @@ -299,6 +300,9 @@ export const App: React.FC = () => { Technique[currentTechnique as keyof typeof Technique] )} visit={selectedVisit} + beamline={beamline} + startTime={session.startTime} + scanIds={selectedScanIds} /> diff --git a/frontend/unified/src/components/ParameterConfiguration/ParameterConfiguration.tsx b/frontend/unified/src/components/ParameterConfiguration/ParameterConfiguration.tsx index 8f39934..f955b81 100644 --- a/frontend/unified/src/components/ParameterConfiguration/ParameterConfiguration.tsx +++ b/frontend/unified/src/components/ParameterConfiguration/ParameterConfiguration.tsx @@ -1,5 +1,5 @@ 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"; @@ -7,7 +7,8 @@ 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; @@ -15,6 +16,9 @@ type ParameterConfigurationProps = { setTemplate: (_: string) => void; availableTemplates: Option[]; visit: Visit; + beamline: Beamline; + startTime: InstrumentSession["startTime"]; + scanIds: number[]; }; /** @@ -28,9 +32,27 @@ 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 = ({ technique, @@ -38,6 +60,9 @@ export const ParameterConfiguration: React.FC = ({ setTemplate, availableTemplates, visit, + beamline, + startTime, + scanIds, }: ParameterConfigurationProps) => { const [templateParameters, setTemplateParameters] = useState({}); const [resourceParameters] = useState({ @@ -47,12 +72,20 @@ export const ParameterConfiguration: React.FC = ({ 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, }; diff --git a/frontend/unified/src/components/SessionSelector.tsx b/frontend/unified/src/components/SessionSelector.tsx index a09dfbd..e5bbcf5 100644 --- a/frontend/unified/src/components/SessionSelector.tsx +++ b/frontend/unified/src/components/SessionSelector.tsx @@ -30,6 +30,7 @@ export const GET_SESSION_BY_REFERENCE: TypedDocumentNode< proposalNumber proposalCategory } + startTime } } `; diff --git a/frontend/unified/src/types.ts b/frontend/unified/src/types.ts index e90c2c5..49d6c07 100644 --- a/frontend/unified/src/types.ts +++ b/frontend/unified/src/types.ts @@ -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 };