Skip to content

Commit

Permalink
Rename Environments with AI Apps (user visible) (#369)
Browse files Browse the repository at this point in the history
* rename with AI Apps

* replace in tasks
  • Loading branch information
feloy authored Feb 22, 2024
1 parent 48f81d9 commit 58c0218
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions packages/backend/src/managers/applicationManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ describe('createApplicationPod', () => {
error: 'Something went wrong while creating pod: error createPod',
id: expect.any(String),
state: 'error',
name: 'Creating application',
name: 'Creating AI App',
labels: {},
});
});
Expand All @@ -899,7 +899,7 @@ describe('createApplicationPod', () => {
expect(mocks.updateTaskMock).toBeCalledWith({
id: expect.any(String),
state: 'success',
name: 'Creating application',
name: 'Creating AI App',
labels: {
'pod-id': pod.Id,
},
Expand All @@ -920,7 +920,7 @@ describe('createApplicationPod', () => {
id: expect.any(String),
state: 'error',
error: 'Something went wrong while creating pod: error',
name: 'Creating application',
name: 'Creating AI App',
labels: {
'pod-id': pod.Id,
},
Expand Down
20 changes: 10 additions & 10 deletions packages/backend/src/managers/applicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class ApplicationManager {
}

async runApplication(podInfo: ApplicationPodInfo, labels?: { [key: string]: string }) {
const task = this.taskRegistry.createTask('Starting application', 'loading', labels);
const task = this.taskRegistry.createTask('Starting AI App', 'loading', labels);

// it starts the pod
await containerEngine.startPod(podInfo.engineId, podInfo.Id);
Expand All @@ -191,7 +191,7 @@ export class ApplicationManager {
this.taskRegistry.updateTask({
...task,
state: 'success',
name: 'Application is running',
name: 'AI App is running',
});
}

Expand All @@ -215,7 +215,7 @@ export class ApplicationManager {
modelPath: string,
labels?: { [key: string]: string },
): Promise<ApplicationPodInfo> {
const task = this.taskRegistry.createTask('Creating application', 'loading', labels);
const task = this.taskRegistry.createTask('Creating AI App', 'loading', labels);

// create empty pod
let podInfo: ApplicationPodInfo;
Expand Down Expand Up @@ -591,7 +591,7 @@ export class ApplicationManager {
this.podmanConnection.onMachineStop(() => {
// Podman Machine has been stopped, we consider all recipe pods are stopped
for (const recipeModelIndex of this.#applications.keys()) {
this.taskRegistry.createTask('Application stopped manually', 'success', {
this.taskRegistry.createTask('AI App stopped manually', 'success', {
'recipe-id': recipeModelIndex.recipeId,
'model-id': recipeModelIndex.modelId,
});
Expand Down Expand Up @@ -647,7 +647,7 @@ export class ApplicationManager {

const protect = this.protectTasks.has(pod.Id);
if (!protect) {
this.taskRegistry.createTask('Application stopped manually', 'success', {
this.taskRegistry.createTask('AI App stopped manually', 'success', {
'recipe-id': recipeId,
'model-id': modelId,
});
Expand All @@ -674,7 +674,7 @@ export class ApplicationManager {

const protect = this.protectTasks.has(podId);
if (!protect) {
this.taskRegistry.createTask('Application stopped manually', 'success', {
this.taskRegistry.createTask('AI App stopped manually', 'success', {
'recipe-id': recipeId,
'model-id': modelId,
});
Expand Down Expand Up @@ -710,7 +710,7 @@ export class ApplicationManager {
'model-id': modelId,
});

const stoppingTask = this.taskRegistry.createTask(`Stopping application`, 'loading', {
const stoppingTask = this.taskRegistry.createTask(`Stopping AI App`, 'loading', {
'recipe-id': recipeId,
'model-id': modelId,
});
Expand All @@ -722,7 +722,7 @@ export class ApplicationManager {
// continue when the pod is already stopped
if (!String(err).includes('pod already stopped')) {
stoppingTask.error = 'error stopping the pod. Please try to stop and remove the pod manually';
stoppingTask.name = 'Error stopping application';
stoppingTask.name = 'Error stopping AI App';
this.taskRegistry.updateTask(stoppingTask);
throw err;
}
Expand All @@ -731,10 +731,10 @@ export class ApplicationManager {
await containerEngine.removePod(envPod.engineId, envPod.Id);

stoppingTask.state = 'success';
stoppingTask.name = `Application stopped`;
stoppingTask.name = `AI App stopped`;
} catch (err: unknown) {
stoppingTask.error = 'error removing the pod. Please try to remove the pod manually';
stoppingTask.name = 'Error stopping application';
stoppingTask.name = 'Error stopping AI App';
throw err;
} finally {
this.taskRegistry.updateTask(stoppingTask);
Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ export class StudioApiImpl implements StudioAPI {
// Do not wait on the promise as the api would probably timeout before the user answer.
podmanDesktopApi.window
.showWarningMessage(
`Stop the environment "${recipe.name}"? This will delete the containers running the application and model.`,
`Stop the AI App "${recipe.name}"? This will delete the containers running the application and model.`,
'Confirm',
'Cancel',
)
.then((result: string) => {
if (result === 'Confirm') {
this.applicationManager.deleteEnvironment(recipeId, modelId).catch((err: unknown) => {
console.error(`error deleting environment pod: ${String(err)}`);
console.error(`error deleting AI App's pod: ${String(err)}`);
podmanDesktopApi.window
.showErrorMessage(
`Error deleting the environment "${recipe.name}". You can try to stop and delete the environment's pod manually.`,
`Error deleting the AI App "${recipe.name}". You can try to stop and delete the AI App's pod manually.`,
)
.catch((err: unknown) => {
console.error(`Something went wrong with confirmation modals`, err);
Expand All @@ -189,16 +189,16 @@ export class StudioApiImpl implements StudioAPI {
// Do not wait on the promise as the api would probably timeout before the user answer.
podmanDesktopApi.window
.showWarningMessage(
`Restart the environment "${recipe.name}"? This will delete the containers running the application and model, rebuild the images with the current sources, and restart the containers.`,
`Restart the AI App "${recipe.name}"? This will delete the containers running the application and model, rebuild the images with the current sources, and restart the containers.`,
'Confirm',
'Cancel',
)
.then((result: string) => {
if (result === 'Confirm') {
this.applicationManager.restartEnvironment(recipeId, modelId).catch((err: unknown) => {
console.error(`error restarting environment: ${String(err)}`);
console.error(`error restarting AI App: ${String(err)}`);
podmanDesktopApi.window
.showErrorMessage(`Error restarting the environment "${recipe.name}"`)
.showErrorMessage(`Error restarting the AI App "${recipe.name}"`)
.catch((err: unknown) => {
console.error(`Something went wrong with confirmation modals`, err);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ onMount(() => {
</Route>

<!-- Environments -->
<Route path="/environments" breadcrumb="Environments">
<Route path="/environments" breadcrumb="AI Apps">
<Environments />
</Route>

Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/lib/EnvironmentActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ export let modelId: string;
function stopEnvironment() {
studioClient.requestRemoveEnvironment(recipeId, modelId).catch(err => {
console.error(`Something went wrong while trying to stop environment: ${String(err)}.`);
console.error(`Something went wrong while trying to stop AI App: ${String(err)}.`);
});
}
function restartEnvironment() {
studioClient.requestRestartEnvironment(recipeId, modelId).catch(err => {
console.error(`Something went wrong while trying to restart environment: ${String(err)}.`);
console.error(`Something went wrong while trying to restart AI App: ${String(err)}.`);
});
}
</script>

{#if object?.pod !== undefined}
<ListItemButtonIcon icon="{faStop}" onClick="{() => stopEnvironment()}" title="Stop Environment" />
<ListItemButtonIcon icon="{faStop}" onClick="{() => stopEnvironment()}" title="Stop AI App" />

<ListItemButtonIcon icon="{faRotateForward}" onClick="{() => restartEnvironment()}" title="Restart Environment" />
<ListItemButtonIcon icon="{faRotateForward}" onClick="{() => restartEnvironment()}" title="Restart AI App" />
{/if}
2 changes: 1 addition & 1 deletion packages/frontend/src/lib/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export let meta: TinroRouteMeta;
<div class="h-full overflow-hidden hover:overflow-y-auto" style="margin-bottom:auto">
<SettingsNavItem title="Recipe Catalog" href="/recipes" bind:meta="{meta}" />

<SettingsNavItem title="Environments" href="/environments" bind:meta="{meta}" />
<SettingsNavItem title="AI Apps" href="/environments" bind:meta="{meta}" />

<SettingsNavItem title="Models" href="/models" bind:meta="{meta}" />

Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/lib/RecipeDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ test('should call runApplication execution when run application button is clicke
modelId: 'model1',
});

const btnRunApplication = screen.getByText('Start application');
const btnRunApplication = screen.getByText('Start AI App');
await userEvent.click(btnRunApplication);

expect(mocks.pullApplicationMock).toBeCalledWith('recipe 1', 'model1');
Expand Down Expand Up @@ -263,12 +263,12 @@ test('start application button should be the only one displayed', async () => {
modelId: 'model1',
});

const btnRunApplication = screen.getByText('Start application');
const btnRunApplication = screen.getByText('Start AI App');
expect(btnRunApplication).toBeInTheDocument();

const btnStop = screen.queryByTitle('Stop Environment');
const btnStop = screen.queryByTitle('Stop AI App');
expect(btnStop).toBeNull();

const btnRestart = screen.queryByTitle('Restart Environment');
const btnRestart = screen.queryByTitle('Restart AI App');
expect(btnRestart).toBeNull();
});
6 changes: 3 additions & 3 deletions packages/frontend/src/lib/RecipeDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const navigateToPod = () => {
function startApplication() {
studioClient.pullApplication(recipeId, modelId).catch((err: unknown) => {
console.error('Something went wrong while pulling application', err);
console.error('Something went wrong while pulling AI App', err);
});
}
</script>
Expand All @@ -77,7 +77,7 @@ function startApplication() {
aria-label="application details panel">
<div class="flex flex-col px-4 space-y-4 mx-auto">
<div class="w-full flex flex-row justify-between max-lg:hidden">
<span class="text-base">Application Details</span>
<span class="text-base">AI App Details</span>
<button on:click="{toggle}" aria-label="hide application details"
><i class="fas fa-angle-right text-gray-900"></i></button>
</div>
Expand All @@ -103,7 +103,7 @@ function startApplication() {
</div>
{:else}
<Button inProgress="{runningTask !== undefined}" on:click="{startApplication}" class="grow text-gray-500">
Start application
Start AI App
</Button>
{/if}
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/Environments.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const columns: Column<EnvironmentCell>[] = [
const row = new Row<EnvironmentCell>({});
</script>

<NavPage title="Environments" searchEnabled="{false}">
<NavPage title="AI Apps" searchEnabled="{false}">
<div slot="content" class="flex flex-col min-w-full min-h-full">
<div class="min-w-full min-h-full flex-1">
<div class="mt-4 px-5 space-y-5 h-full">
{#if data.length > 0}
<Table kind="environment" data="{data}" columns="{columns}" row="{row}"></Table>
<Table kind="AI App" data="{data}" columns="{columns}" row="{row}"></Table>
{:else}
<div role="status">There is no environment yet</div>
<div role="status">There is no AI App yet</div>
{/if}
</div>
</div>
Expand Down

0 comments on commit 58c0218

Please sign in to comment.