Skip to content

Commit

Permalink
Merge branch 'main' of github.com:transformerlab/transformerlab-app
Browse files Browse the repository at this point in the history
  • Loading branch information
aliasaria committed Jan 31, 2024
2 parents c9639c1 + 4752689 commit a747cb0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
33 changes: 12 additions & 21 deletions src/renderer/components/Experiment/Export/Export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ import {
ClockIcon,
} from 'lucide-react';

// run an exporter plugin on the current experiment's model
function exportRun(
experimentId: string,
plugin: string
) {
return fetch(
chatAPI.Endpoints.Experiment.RunExport(experimentId, plugin)
);
}

// fetcher used by SWR
const fetcher = (url) => fetch(url).then((res) => res.json());

Expand Down Expand Up @@ -66,6 +56,16 @@ export default function Export({experimentInfo}) {
&& supported_architectures.includes(experimentInfo?.config?.foundation_model_architecture);
}

// run an exporter plugin on the current experiment's model
async function exportRun(experiment_id: string, plugin_id: string) {
setJobId(-1);
const response = await fetch(chatAPI.Endpoints.Experiment.RunExport(experiment_id, plugin_id));

// If we want to track job details we can get this from response
// But as long as jobId isn't < 0 the spinner on the export button will stop
setJobId(null);
}

return (
<>

Expand All @@ -74,7 +74,6 @@ export default function Export({experimentInfo}) {
setJobId={setViewExportDetails}
/>

{/** Temporarily disable plugin settings modal until testing complete
<PluginSettingsModal
open = {pluginModalOpen}
onClose={() => {
Expand All @@ -83,10 +82,10 @@ export default function Export({experimentInfo}) {
setPluginModalOpen(false);
//mutate();
}}
onSubmit={exportRun}
experimentInfo = {experimentInfo}
pluginId = {selectedPlugin}
/>
*/}

<Sheet
sx={{
Expand Down Expand Up @@ -133,19 +132,11 @@ export default function Export({experimentInfo}) {
color="success"
variant="soft"
onClick={async (e) => {
setJobId(-1);
setSelectedPlugin(row.uniqueId);
setPluginModalOpen(true);

// Currently this call blocks until the export is done
const response = await exportRun(
experimentInfo.id,
row.uniqueId
);

// If we want to track job details we can get this from response
// But as long as jobId isn't < 0 the spinner on the export button will stop
setJobId(null);
// const response = await exportRun(experimentInfo.id, row.uniqueId);
}}
disabled={!isModelValidArchitecture(row.model_architectures)}
>
Expand Down
19 changes: 11 additions & 8 deletions src/renderer/components/Experiment/Export/PluginSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ function defaultOutputModelName(input_model_name, plugin_info) {
return input_model_name + plugin_info;
}

export default function PluginSettingsModal({ open, onClose, experimentInfo, pluginId }) {
/**
* PluginSettingsModal
* open is a boolean stored in state by Export to know if this modal is open
* onClose is a function that gets executed anytime this modal gets closed (cancel or submit)
* onSubmit is a function that gets executed only when this form is submitted
*/
export default function PluginSettingsModal({ open, onClose, onSubmit, experimentInfo, pluginId }) {

const [selectedPlugin, setSelectedPlugin] = useState(null);
const [config, setConfig] = useState(DefaultPluginConfig);
Expand Down Expand Up @@ -74,13 +80,10 @@ export default function PluginSettingsModal({ open, onClose, experimentInfo, plu
}}
onSubmit={(event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
const formData = new FormData(event.currentTarget);
const formJson = Object.fromEntries((formData as any).entries());
/**chatAPI.RunExport(
experimentInfo?.id,
pluginId,
JSON.stringify(formJson)
);*/
const form_data = new FormData(event.currentTarget);
const form_json = Object.fromEntries((form_data as any).entries());

onSubmit(experimentInfo.id, pluginId);
onClose();
}}
>
Expand Down

0 comments on commit a747cb0

Please sign in to comment.