-
Notifications
You must be signed in to change notification settings - Fork 8
fix: fix build speed (#1021) #1023
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c25d964
fix: check if build speed can be improved (#1021)
frano-m df3957d
feat: added tests for workflows service (#1021)
frano-m 4a78700
refactor: error (#1021)
frano-m 309e4fd
fix: early exit on loading workflows (#1021)
frano-m a41ffad
fix: clear json from public api folder prior to copying new json (#1021)
frano-m 5b6d4b4
fix: reuse of page props in workflow inputs view (#1021)
frano-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
...uts/components/Main/components/Stepper/components/Step/GTFStep/hooks/UseUCSCFiles/hook.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
...nts/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
app/components/Entity/components/ConfigureWorkflowInputs/components/Main/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,15 @@ | ||
| import { | ||
| BRCDataCatalogGenome, | ||
| Workflow, | ||
| } from "../../../../../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { Workflow } from "../../../../../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { | ||
| ConfiguredInput, | ||
| OnConfigure, | ||
| } from "../../../../../../views/WorkflowInputsView/hooks/UseConfigureInputs/types"; | ||
| import { GA2AssemblyEntity } from "../../../../../../apis/catalog/ga2/entities"; | ||
| import { StepConfig } from "./components/Stepper/components/Step/types"; | ||
| import { Assembly } from "../../../../../../views/WorkflowInputsView/types"; | ||
|
|
||
| export interface Props { | ||
| configuredInput: ConfiguredInput; | ||
| configuredSteps: StepConfig[]; | ||
| genome: BRCDataCatalogGenome | GA2AssemblyEntity; | ||
| genome: Assembly; | ||
| onConfigure: OnConfigure; | ||
| workflow: Workflow; | ||
| } |
9 changes: 3 additions & 6 deletions
9
app/components/Entity/components/ConfigureWorkflowInputs/components/SideColumn/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,11 @@ | ||
| import { | ||
| BRCDataCatalogGenome, | ||
| Workflow, | ||
| } from "../../../../../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { Workflow } from "../../../../../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { ConfiguredInput } from "../../../../../../views/WorkflowInputsView/hooks/UseConfigureInputs/types"; | ||
| import { GA2AssemblyEntity } from "../../../../../../apis/catalog/ga2/entities"; | ||
| import { StepConfig } from "../../../../../../components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/types"; | ||
| import { Assembly } from "../../../../../../views/WorkflowInputsView/types"; | ||
|
|
||
| export interface Props { | ||
| configuredInput: ConfiguredInput; | ||
| configuredSteps: StepConfig[]; | ||
| genome: BRCDataCatalogGenome | GA2AssemblyEntity; | ||
| genome: Assembly; | ||
| workflow: Workflow; | ||
| } |
2 changes: 1 addition & 1 deletion
2
app/components/Entity/components/ConfigureWorkflowInputs/components/Top/top.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/components/Entity/components/ConfigureWorkflowInputs/components/Top/types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { Workflow } from "../../../../../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { Assembly } from "../../../../../../views/WorkflowInputsView/types"; | ||
|
|
||
| export interface Props { | ||
| entityId: string; | ||
| genome: Assembly; | ||
| workflow: Workflow; | ||
| } |
4 changes: 2 additions & 2 deletions
4
app/components/Entity/components/ConfigureWorkflowInputs/components/Top/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { | ||
| BRCDataCatalogGenome, | ||
| Workflow, | ||
| WorkflowCategory, | ||
| } from "../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { getEntities, getEntity } from "./query"; | ||
| import { GA2AssemblyEntity } from "../../apis/catalog/ga2/entities"; | ||
|
|
||
| /** | ||
| * Gets assemblies. | ||
| * @returns Assemblies. | ||
| */ | ||
| export function getAssemblies< | ||
| T extends BRCDataCatalogGenome | GA2AssemblyEntity, | ||
| >(): T[] { | ||
| return getEntities<T>("assemblies"); | ||
| } | ||
|
|
||
| /** | ||
| * Gets assembly by entity id. | ||
| * @param entityId - Entity id. | ||
| * @returns Assembly. | ||
| */ | ||
| export function getAssembly<T extends BRCDataCatalogGenome | GA2AssemblyEntity>( | ||
| entityId: string | ||
| ): T { | ||
| return getEntity<T>("assemblies", entityId); | ||
| } | ||
|
|
||
| /** | ||
| * Gets workflow by TRS id. | ||
| * @param trsId - TRS id. | ||
| * @returns Workflow. | ||
| */ | ||
| export function getWorkflow(trsId: string): Workflow { | ||
| return getEntity<Workflow>("workflows", trsId); | ||
| } | ||
|
|
||
| /** | ||
| * Gets workflows. | ||
| * @returns Workflows. | ||
| */ | ||
| export function getWorkflows(): WorkflowCategory[] { | ||
| return getEntities<WorkflowCategory>("workflows"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { useEffect, useState } from "react"; | ||
| import { ensureEntitiesLoaded } from "./utils"; | ||
| import { getConfig } from "@databiosphere/findable-ui/lib/config/config"; | ||
|
|
||
| export function useEntities(): boolean { | ||
| const [isLoaded, setIsLoaded] = useState(false); | ||
|
|
||
| const config = getConfig(); | ||
|
|
||
| useEffect(() => { | ||
| if (!config) return; | ||
|
|
||
| ensureEntitiesLoaded(config) | ||
| .then(() => setIsLoaded(true)) | ||
| .catch((err) => { | ||
| throw new Error(`Failed to load entities: ${err}`); | ||
| }); | ||
| }, [config]); | ||
|
|
||
| return isLoaded; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { SiteConfig } from "@databiosphere/findable-ui/lib/config/entities"; | ||
| import { loadEntities, loadWorkflows } from "../../loader"; | ||
|
|
||
| let loadPromise: Promise<void> | null = null; | ||
|
|
||
| /** | ||
| * Ensures that the entities and workflows are loaded. | ||
| * @param config - Site config. | ||
| * @returns Promise that resolves when the entities and workflows are loaded. | ||
| */ | ||
| export function ensureEntitiesLoaded(config: SiteConfig): Promise<void> { | ||
| if (loadPromise) return loadPromise; | ||
|
|
||
| loadPromise = (async (): Promise<void> => { | ||
| await loadWorkflows(); | ||
| await loadEntities(config); | ||
| })(); | ||
|
|
||
| return loadPromise; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { API } from "./routes"; | ||
| import { SiteConfig } from "@databiosphere/findable-ui/lib/config/entities"; | ||
| import { getEntitiesById, setEntitiesById, setEntitiesByType } from "./store"; | ||
| import { EntityRoute } from "./types"; | ||
| import { | ||
| Workflow, | ||
| WorkflowCategory, | ||
| } from "../../apis/catalog/brc-analytics-catalog/common/entities"; | ||
| import { formatTrsId } from "../../components/Entity/components/AnalysisMethodsCatalog/utils"; | ||
| import { CUSTOM_WORKFLOW } from "../../components/Entity/components/AnalysisMethod/components/CustomWorkflow/constants"; | ||
|
|
||
| /** | ||
| * Fetches entities from the API. | ||
| * @param url - URL. | ||
| * @returns Entity list. | ||
| */ | ||
| async function fetchEntities(url: string): Promise<unknown[]> { | ||
| const res = await fetch(url); | ||
|
|
||
| if (!res.ok) throw new Error(`Failed to fetch: ${url}`); | ||
frano-m marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return (await res.json()) as unknown[]; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if the route is an entity route. | ||
| * @param route - Route. | ||
| * @returns True if the route is an entity route; false otherwise. | ||
| */ | ||
| function isEntityRoute(route: string): route is EntityRoute { | ||
| return route in API; | ||
| } | ||
|
|
||
| /** | ||
| * Loads the entities store with entities from the API. | ||
| * @param config - Site config. | ||
| */ | ||
| export async function loadEntities(config: SiteConfig): Promise<void> { | ||
| for (const entity of config.entities) { | ||
| const { getId, route } = entity; | ||
|
|
||
| if (!isEntityRoute(route)) continue; | ||
|
|
||
| const apiRoute = API[route]; | ||
|
|
||
| // Entities are already loaded; skip. | ||
| if (getEntitiesById().has(route)) continue; | ||
|
|
||
| // Get id function is not configured; entities are excluded from preloading. | ||
| if (!getId) continue; | ||
|
|
||
| // Fetch the entities. | ||
| const entities = await fetchEntities(apiRoute); | ||
|
|
||
| const entityById = new Map<string, unknown>(); | ||
| for (const entity of entities) entityById.set(getId(entity), entity); | ||
|
|
||
| setEntitiesById(route, entityById); | ||
| setEntitiesByType(route, entities); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Loads the workflows store with workflows from the API. | ||
| */ | ||
| export async function loadWorkflows(): Promise<void> { | ||
frano-m marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (getEntitiesById().has("workflows")) return; | ||
|
|
||
| const workflowCategories = (await fetchEntities( | ||
| API.workflows | ||
| )) as WorkflowCategory[]; | ||
|
|
||
| const workflows = workflowCategories.flatMap((w) => w.workflows); | ||
|
|
||
| const workflowById = new Map<string, Workflow>(); | ||
|
|
||
| for (const workflow of workflows) { | ||
| workflowById.set(formatTrsId(workflow.trsId), workflow); | ||
| } | ||
|
|
||
| // Add custom workflow. | ||
| workflowById.set(CUSTOM_WORKFLOW.trsId, CUSTOM_WORKFLOW); | ||
|
|
||
| setEntitiesById("workflows", workflowById); | ||
| setEntitiesByType("workflows", workflowCategories); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.