Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(controller): add env for gradio root when web service uses proxy #2996

Merged
merged 1 commit into from
Nov 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,12 @@ public Map<String, String> getContainerEnvs() {

// for online eval
if (task.getStep().getSpec() != null && task.getStep().getSpec().getExpose() != 0) {
coreContainerEnvs.put("SW_ONLINE_SERVING_ROOT_PATH",
webServerInTask.generateServiceRoot(task.getId(), task.getStep().getSpec().getExpose()));
var root = webServerInTask.generateServiceRoot(task.getId(), task.getStep().getSpec().getExpose());
coreContainerEnvs.put("SW_ONLINE_SERVING_ROOT_PATH", root);

// hack for gradio
// https://github.com/gradio-app/gradio/blob/2780d067f9f801016c0254de679b56794859abed/gradio/blocks.py#L601
coreContainerEnvs.put("GRADIO_ROOT_PATH", root);
}

return coreContainerEnvs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

public class SwCliModelHandlerContainerSpecificationTest {

static final String CONDARC = "channels:\n"
static final String CONDA_RC = "channels:\n"
+ " - defaults\n"
+ "show_channel_urls: true\n"
+ "default_channels:\n"
Expand Down Expand Up @@ -159,7 +159,7 @@ public class SwCliModelHandlerContainerSpecificationTest {
@Test
public void testEnvs() throws JsonProcessingException {
RunTimeProperties runTimeProperties = new RunTimeProperties(
"", new RunConfig(), new RunConfig(), new Pypi("indexU", "extraU", "trustedH", 1, 2), CONDARC);
"", new RunConfig(), new RunConfig(), new Pypi("indexU", "extraU", "trustedH", 1, 2), CONDA_RC);
TaskTokenValidator taskTokenValidator = mock(TaskTokenValidator.class);
when(taskTokenValidator.getTaskToken(any(), any())).thenReturn("tt");
var webServerInTask = mock(WebServerInTask.class);
Expand Down Expand Up @@ -191,13 +191,14 @@ public void testEnvs() throws JsonProcessingException {

var envWithSourceRoot = new HashMap<>(expectedEnvsRun);
envWithSourceRoot.put("SW_ONLINE_SERVING_ROOT_PATH", "/gateway/1/1234");
envWithSourceRoot.put("GRADIO_ROOT_PATH", "/gateway/1/1234");
assertMapEquals(envWithSourceRoot, csWithExposed.getContainerEnvs());
}

@Test
public void testDevMode() throws IOException {
RunTimeProperties runTimeProperties = new RunTimeProperties(
"", new RunConfig(), new RunConfig(), new Pypi("indexU", "extraU", "trustedH", 1, 2), CONDARC);
"", new RunConfig(), new RunConfig(), new Pypi("indexU", "extraU", "trustedH", 1, 2), CONDA_RC);
TaskTokenValidator taskTokenValidator = mock(TaskTokenValidator.class);
when(taskTokenValidator.getTaskToken(any(), any())).thenReturn("tt");
var webServerInTask = mock(WebServerInTask.class);
Expand Down
Loading