Skip to content

Commit

Permalink
[fix] Resolve live update failing issue (#3126)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihran113 authored Mar 22, 2024
1 parent 7dd290b commit ed8ac3e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:

jobs:
aim-ui-dist:
if: ${{ github.event_name == 'schedule' || github.actor == 'gorarakelyan' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
if: ${{ github.event_name == 'schedule' || github.actor == 'mihran113' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
python -m twine upload -u __token__ -p "${PYPI_PASSWORD}" dist/*
linux-dist:
if: ${{ github.event_name == 'schedule' || github.actor == 'gorarakelyan' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
if: ${{ github.event_name == 'schedule' || github.actor == 'mihran113' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:
run: . create-docker-image.sh

macos-dist:
if: ${{ github.event_name == 'schedule' || github.actor == 'gorarakelyan' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
if: ${{ github.event_name == 'schedule' || github.actor == 'mihran113' || github.actor == 'alberttorosyan' || github.actor == 'roubkar' }}
runs-on: m1
strategy:
fail-fast: false
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## 3.19.2
## 3.19.2
- Resolve live update failing issue (mihran113)
- Resolve issue with remote tracking protocol probe fail (mihran113)

## 3.19.1 Mar 14, 2024
Expand Down
18 changes: 17 additions & 1 deletion aim/web/ui/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { version } from '../../package.json';

interface GlobalScope extends Window {
API_BASE_PATH?: string;
API_AUTH_TOKEN?: string;
}

let globalScope: GlobalScope;
Expand Down Expand Up @@ -37,6 +38,14 @@ function setAPIBasePath(basePath: string) {
: `${getBasePath()}/api`;
}

function setAPIAuthToken(authToken: string) {
globalScope.API_AUTH_TOKEN = authToken;
}

function getAPIAuthToken() {
return `${globalScope.API_AUTH_TOKEN}`;
}

export const AIM_VERSION = version;

const PATHS_TO_SHOW_CACHE_BANNERS = ['notebook', 'aim-sage'];
Expand All @@ -48,4 +57,11 @@ export function checkIsBasePathInCachedEnv(basePath: string) {
return PATHS_TO_SHOW_CACHE_BANNERS.includes(parsed_path);
}

export { isDEVModeOn, getBasePath, getAPIHost, setAPIBasePath };
export {
isDEVModeOn,
getBasePath,
getAPIHost,
setAPIBasePath,
setAPIAuthToken,
getAPIAuthToken,
};
5 changes: 4 additions & 1 deletion aim/web/ui/src/services/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Cookies from 'js-cookie';

import { getAPIHost } from 'config/config';
import { getAPIHost, getAPIAuthToken } from 'config/config';

import ENDPOINTS from './endpoints';

Expand Down Expand Up @@ -253,6 +253,9 @@ function getRequestHeaders(headers = {}) {
* @returns {string} - The token
*/
function getAuthToken(): string {
if (typeof window === 'undefined') {
return getAPIAuthToken();
}
return localStorage.getItem(AUTH_TOKEN_KEY) || '';
}

Expand Down
7 changes: 6 additions & 1 deletion aim/web/ui/src/services/live-update/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import * as Comlink from 'comlink';

import { setAPIBasePath } from 'config/config';
import { setAPIBasePath, setAPIAuthToken } from 'config/config';

import {
decodeBufferPairs,
Expand Down Expand Up @@ -254,13 +254,18 @@ function replaceBasePath(basePath: string) {
setAPIBasePath(basePath);
}

function setAuthToken(authToken: string) {
setAPIAuthToken(authToken);
}

const WebWorker = {
subscribeToApiCallResult,
setConfig,
start,
close,
stop,
replaceBasePath,
setAuthToken,
};

export type IWorker = typeof WebWorker;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class UpdateService {

this.instance = new LUWorker();
this.instance.replaceBasePath(window.API_BASE_PATH);
this.instance.setAuthToken(localStorage.getItem('Auth') || '');
this.instance.setConfig(
appName,
embeddedAppNames[this.appName].endpoint,
Expand Down

0 comments on commit ed8ac3e

Please sign in to comment.