Merge branch 'main' into operator-menu

This commit is contained in:
Faton Ramadani
2023-12-29 16:54:12 +01:00
committed by GitHub
3 changed files with 138 additions and 9 deletions
+15 -4
View File
@@ -83,14 +83,24 @@ pub async fn pip_compile(
WORKER_CONFIG.read().await.pip_local_dependencies.as_ref()
{
let deps = pip_local_dependencies.clone();
let compiled_deps = deps.iter().map(|dep| {
let compiled_dep = Regex::new(dep);
match compiled_dep {
Ok(compiled_dep) => Some(compiled_dep),
Err(e) => {
tracing::warn!("regex compilation failed for Python local dependency: '{}' - it will be ignored", e);
return None;
}
}
}).filter(|dep_maybe| dep_maybe.is_some()).map(|dep| dep.unwrap()).collect::<Vec<Regex>>();
requirements
.lines()
.filter(|s| {
if !deps.contains(&s.to_string()) {
return true;
} else {
if compiled_deps.iter().any(|dep| dep.is_match(s)) {
logs.push_str(&format!("\nignoring local dependency: {}", s));
return false;
} else {
return true;
}
})
.join("\n")
@@ -566,7 +576,7 @@ async fn handle_python_deps(
};
if requirements.len() > 0 {
additional_python_paths = handle_python_reqs(
let mut venv_path = handle_python_reqs(
requirements
.split("\n")
.filter(|x| !x.starts_with("--"))
@@ -582,6 +592,7 @@ async fn handle_python_deps(
worker_dir,
)
.await?;
additional_python_paths.append(&mut venv_path);
}
Ok(additional_python_paths)
}
+18 -3
View File
@@ -1,17 +1,32 @@
<script lang="ts">
import { enterpriseLicense } from '$lib/stores'
import { AlertTriangle } from 'lucide-svelte'
import { AlertTriangle, ChevronDown, ChevronRight } from 'lucide-svelte'
import Tooltip from './Tooltip.svelte'
export let label: string | undefined = undefined
export let tooltip: string | undefined = undefined
export let eeOnly = false
export let collapsable: boolean = false
let collapsed: boolean = true
</script>
<div class="w-full">
<div class="flex flex-row justify-between items-center mb-2">
<h2 class="text-base font-semibold flex flex-row gap-1">
{label}
{#if collapsable}
<button class="flex items-center gap-1" on:click={() => (collapsed = !collapsed)}>
{#if collapsed}
<ChevronRight size={16} />
{:else}
<ChevronDown size={16} />
{/if}
{label}
</button>
{:else}
{label}
{/if}
<slot name="header" />
{#if tooltip}
<Tooltip>{tooltip}</Tooltip>
@@ -27,7 +42,7 @@
</h2>
<slot name="action" />
</div>
<div class={$$props.class}>
<div class={collapsable && collapsed ? `hidden ${$$props.class}` : `${$$props.class}`}>
<slot />
</div>
</div>
@@ -26,6 +26,8 @@
priority_tags?: Map<string, number>
cache_clear?: number
init_bash?: string
additional_python_paths?: string[]
pip_local_dependencies?: string[]
}
export let activeWorkers: number
export let customTags: string[] | undefined
@@ -38,6 +40,8 @@
init_bash?: string
env_vars_static?: Map<string, string>
env_vars_allowlist?: string[]
additional_python_paths?: string[]
pip_local_dependencies?: string[]
} = {}
function loadNConfig() {
@@ -402,11 +406,110 @@
>
{/if}
{/if}
<div class="mt-8" />
<Section
label="Python runtime settings"
collapsable={true}
tooltip="Add Python runtime specific settings like additional python paths and PIP local dependencies"
>
<div class="flex flex-col gap-3 gap-y-2 pb-2 max-w">
<span class="text-sm text-primary">Additional Python Paths</span>
{#each nconfig.additional_python_paths ?? [] as additional_python_path, i}
<div class="flex gap-1 items-center">
<input
type="text"
placeholder="/path/to/python3.X/site-packages"
bind:value={additional_python_path}
/>
<button
class="rounded-full bg-surface/60 hover:bg-gray-200"
aria-label="Clear"
on:click={() => {
if (
nconfig.additional_python_paths === undefined ||
nconfig.additional_python_paths.length == 0
) {
return
}
nconfig.additional_python_paths.splice(i, 1)
nconfig.additional_python_paths = [...nconfig.additional_python_paths]
dirty = true
}}
>
<X size={14} />
</button>
</div>
{/each}
<div class="flex">
<Button
variant="contained"
color="blue"
size="xs"
startIcon={{ icon: Plus }}
on:click={() => {
if (nconfig.additional_python_paths === undefined) {
nconfig.additional_python_paths = []
}
nconfig.additional_python_paths.push('')
nconfig.additional_python_paths = [...nconfig.additional_python_paths]
dirty = true
}}
>
Add Additional Python Path
</Button>
</div>
<span class="text-sm text-primary">PIP local dependencies</span>
{#each nconfig.pip_local_dependencies ?? [] as pip_local_dependency, i}
<div class="flex gap-1 items-center">
<input type="text" placeholder="httpx" bind:value={pip_local_dependency} />
<button
class="rounded-full bg-surface/60 hover:bg-gray-200"
aria-label="Clear"
on:click={() => {
if (
nconfig.pip_local_dependencies === undefined ||
nconfig.pip_local_dependencies.length == 0
) {
return
}
nconfig.pip_local_dependencies.splice(i, 1)
nconfig.pip_local_dependencies = [...nconfig.pip_local_dependencies]
dirty = true
}}
>
<X size={14} />
</button>
</div>
{/each}
<div class="flex">
<Button
variant="contained"
color="blue"
size="xs"
startIcon={{ icon: Plus }}
on:click={() => {
if (nconfig.pip_local_dependencies === undefined) {
nconfig.pip_local_dependencies = []
}
nconfig.pip_local_dependencies.push('')
nconfig.pip_local_dependencies = [...nconfig.pip_local_dependencies]
dirty = true
}}
>
Add PIP local dependency
</Button>
</div>
</div>
</Section>
<div class="mt-8" />
<Section
label="Worker Environment Variables"
tooltip="Add static and dynamic environment variables to workers. Dynamic environment variable values will be loaded from the worker host environment variables while static environment variables will be set directly from their values below."
label="Environment Variables passed to Jobs"
collapsable={true}
tooltip="Add static and dynamic environment variables that will be passed to jobs handled by this worker group. Dynamic environment variable values will be loaded from the worker host environment variables while static environment variables will be set directly from their values below."
>
<div class="flex flex-col gap-3 gap-y-2 pb-2 max-w">
{#each customEnvVars as envvar, i}