Skip to content

Commit

Permalink
Fixed local mode
Browse files Browse the repository at this point in the history
  • Loading branch information
nicedexter committed Nov 12, 2019
1 parent e4fc599 commit e04225d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
23 changes: 13 additions & 10 deletions src/components/API/Core.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { backendURL } from '../API';
import { ENABLED_ALGORITHMS, UI_HIDDEN_PARAMETERS } from '../constants';
import { Engine } from './Experiment';
import { buildWorkflowAlgorithmList } from './WorkflowAPIAdapter';
import { InstanceMode } from '../App/App';

export interface Variable {
code: string;
Expand Down Expand Up @@ -288,7 +289,7 @@ class Core extends Container<State> {
}
};

public algorithms = async (): Promise<void> => {
public algorithms = async (mode: InstanceMode): Promise<void> => {
const exaremeAlgorithms = await this.exaremeAlgorithms();
this.setState(state => ({
...state,
Expand All @@ -299,15 +300,17 @@ class Core extends Container<State> {
error: undefined
}));

const workflows = await this.workflows();
this.setState(state => ({
...state,
algorithms: [
...(state.algorithms || []),
...((workflows && workflows.data) || [])
],
error: workflows.error ? workflows.error : undefined
}));
if (mode === InstanceMode.Federation) {
const workflows = await this.workflows();
this.setState(state => ({
...state,
algorithms: [
...(state.algorithms || []),
...((workflows && workflows.data) || [])
],
error: workflows.error ? workflows.error : undefined
}));
}

return Promise.resolve();
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/API/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import APIExperiment, {
} from './Experiment';
import APIModel, { ModelResponse, ModelState } from './Model';
import config from './RequestHeaders';
import { InstanceMode } from '../App/App';

const apiModel = new APIModel(config);
const apiExperiment = new APIExperiment(config);
Expand Down Expand Up @@ -48,7 +49,7 @@ const createWorkflowPayload = async (
parameters: AlgorithmParameter[],
modelSlug: string
): Promise<ExperimentPayload | void> => {
await apiCore.algorithms();
await apiCore.algorithms(InstanceMode.Local);
const algorithms = apiCore.state.algorithms || [];
const selectedAlgorithm = algorithms.find(a => a.code === experimentCode);

Expand Down
9 changes: 6 additions & 3 deletions src/components/App/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ class AppContainer extends React.Component<any, State> {
// }

// Conf written by dockerize
let appConfig: AppConfig;
const response = await fetch(`${webURL}/static/config.json`);
try {
const config = await response.json();
const appConfig = {
appConfig = {
...config,
mode:
config.mode === 'federation'
Expand All @@ -57,7 +58,7 @@ class AppContainer extends React.Component<any, State> {
ReactGA.initialize(appConfig.ga);
}
} catch (e) {
const appConfig: AppConfig = {
appConfig = {
instanceName: 'MIP DEV',
mode: InstanceMode.Local,
version: 'alpha'
Expand All @@ -75,7 +76,9 @@ class AppContainer extends React.Component<any, State> {
this.apiUser.profile({ username }),
this.apiExperiment.all(),
this.apiCore.fetchPathologies(),
this.apiCore.algorithms(),
this.apiCore.algorithms(
(appConfig && appConfig.mode) || InstanceMode.Local
),
this.apiCore.articles(),
this.apiModel.all()
]);
Expand Down

0 comments on commit e04225d

Please sign in to comment.