Skip to content

Commit

Permalink
Remove heavyweight_process setting
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Nov 16, 2024
1 parent 494002d commit 01e6cee
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 53 deletions.
1 change: 0 additions & 1 deletion src/api_client/site-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const SiteSettingsSchema = z.object({
allow_registration: z.boolean(),
allow_upload: z.boolean(),
skip_patterns: z.string(),
heavyweight_process: z.number().nullable(),
map_api_key: z.string(),
map_api_provider: z.string(),
captioning_model: z.string(),
Expand Down
52 changes: 1 addition & 51 deletions src/layouts/settings/SiteSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import { useTranslation } from "react-i18next";

import { useGetSettingsQuery, useUpdateSettingsMutation } from "../../api_client/site-settings";

const MAX_HEAVYWEIGHT_PROCESSES = 10;
const heavyweightProcessOptions = Array(MAX_HEAVYWEIGHT_PROCESSES)
.fill("")
.map((_, i) => (i + 1).toString());

const MAP_API_PROVIDERS = [
{ value: "mapbox", label: "Mapbox", data: { use_api_key: true, url: "https://www.mapbox.com/" } },
{ value: "maptiler", label: "MapTiler", data: { use_api_key: true, url: "https://www.maptiler.com/" } },
Expand Down Expand Up @@ -53,7 +48,6 @@ export function SiteSettings() {
const [skipPatterns, setSkipPatterns] = useState("");
const [mapApiKey, setMapApiKey] = useState("");
const [mapApiProvider, setMapApiProvider] = useState<string>("proton");
const [heavyweightProcess, setHeavyweightProcess] = useState(1);
const [allowRegistration, setAllowRegistration] = useState(false);
const [allowUpload, setAllowUpload] = useState(false);
const [captioningModel, setCaptioningModel] = useState("im2txt");
Expand All @@ -65,11 +59,6 @@ export function SiteSettings() {
const [opened, { open, close }] = useDisclosure(false);

const saveSettingsWithValidation = (input: any) => {
if (input.heavyweight_process && input.heavyweight_process > 3) {
setWarning("heavyweight");
open();
return;
}
if (input.captioning_model === "blip_base_capfilt_large") {
setWarning("blip");
open();
Expand All @@ -83,7 +72,6 @@ export function SiteSettings() {
setSkipPatterns(settings.skip_patterns);
setMapApiKey(settings.map_api_key);
setMapApiProvider(settings.map_api_provider);
setHeavyweightProcess(settings.heavyweight_process);
setAllowRegistration(settings.allow_registration);
setAllowUpload(settings.allow_upload);
setCaptioningModel(settings.captioning_model);
Expand All @@ -100,29 +88,19 @@ export function SiteSettings() {
setCaptioningModel("im2txt");
saveSettings({ captioning_model: "im2txt" });
}
if (warning === "heavyweight") {
setHeavyweightProcess(3);
saveSettings({ heavyweight_process: 3 });
}
close();
}}
title={<Title order={4}>{t("sitesettings.ram_warning_header")}</Title>}
>
<Stack>
<Text>
{warning === "blip" ? t("sitesettings.blip_warning") : t("sitesettings.heavyweight_process_warning")}
</Text>
<Text>{t("sitesettings.blip_warning")}</Text>
<Group>
<Button
onClick={() => {
if (warning === "blip") {
setCaptioningModel("im2txt");
saveSettings({ captioning_model: "im2txt" });
}
if (warning === "heavyweight") {
setHeavyweightProcess(3);
saveSettings({ heavyweight_process: 3 });
}
close();
}}
>
Expand All @@ -133,9 +111,6 @@ export function SiteSettings() {
if (warning === "blip") {
saveSettings({ captioning_model: captioningModel });
}
if (warning === "heavyweight") {
saveSettings({ heavyweight_process: heavyweightProcess });
}
close();
}}
color="red"
Expand Down Expand Up @@ -278,31 +253,6 @@ export function SiteSettings() {
}}
/>
</Grid.Col>
<Grid.Col span={8}>
<Stack spacing={0}>
<Text>{t("sitesettings.headerheavyweight")}</Text>
<Text fz="sm" color="dimmed">
{t("sitesettings.heavyweight")}
</Text>
</Stack>
</Grid.Col>
<Grid.Col span={4}>
<NativeSelect
data={heavyweightProcessOptions}
value={heavyweightProcess}
onKeyDown={e => {
if (e.key === "Enter") {
saveSettingsWithValidation({ heavyweight_process: +e.currentTarget.value });
}
}}
onChange={e => {
if (/^([0-9\b]+)?$/.test(e.target.value)) {
setHeavyweightProcess(+e.currentTarget.value);
saveSettingsWithValidation({ heavyweight_process: +e.target.value });
}
}}
/>
</Grid.Col>
</Grid>
</Stack>
</Card>
Expand Down
1 change: 0 additions & 1 deletion src/reducers/utilReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const initialState = {
allow_registration: false,
allow_upload: false,
skip_patterns: "",
heavyweight_process: 1,
map_api_key: "",
},
fetchingSiteSettings: false,
Expand Down

0 comments on commit 01e6cee

Please sign in to comment.