Skip to content

Commit

Permalink
Start adding jobmanager for #457
Browse files Browse the repository at this point in the history
  • Loading branch information
dariober committed Nov 15, 2024
1 parent a59fef7 commit b618046
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface OntologyStoreOptions {
indexFields?: { displayName: string; jsonPath: string }[]
}
maxSearchResults?: number
update?(message: string, progress: number): void
}

export interface PropertiesOptions {
Expand Down Expand Up @@ -115,8 +116,8 @@ export default class OntologyStore {
this.ontologyName = name
this.ontologyVersion = version
this.sourceLocation = source
this.db = this.prepareDatabase()
this.options = options ?? {}
this.db = this.prepareDatabase()
}

/**
Expand Down Expand Up @@ -182,8 +183,12 @@ export default class OntologyStore {
}

try {
const { sourceLocation, sourceType } = this
const { options, sourceLocation, sourceType } = this
if (sourceType === 'obo-graph-json') {
if (options.update) {
options.update('Importing', 0)
}
// add more updates inside `loadOboGraphJson`
await this.loadOboGraphJson(db)
} else {
throw new Error(
Expand Down
20 changes: 20 additions & 0 deletions packages/jbrowse-plugin-apollo/src/session/ClientDataStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
} from '../OntologyManager'
import { ApolloRootModel } from '../types'
import { autorun } from 'mobx'
import { ApolloSessionModel } from './session'

export function clientDataStoreFactory(
AnnotationFeatureExtended: typeof AnnotationFeatureModel,
Expand Down Expand Up @@ -164,8 +165,27 @@ export function clientDataStoreFactory(
) as TextIndexFieldDefinition[],
]
if (!ontologyManager.findOntology(name)) {
// eslint-disable-next-line no-inner-declarations
function update(message: string, progress: number) {
const session = getSession(
self,
) as unknown as ApolloSessionModel
const { jobsManager } = session
const controller = new AbortController()
const job = {
name: message,
statusMessage: 'Uploading ontology, this may take awhile',
progressPct: progress,
cancelCallback: () => {
controller.abort()
jobsManager.abortJob(job.name)
},
}
jobsManager.runJob(job)
}
ontologyManager.addOntology(name, version, source, {
textIndexing: { indexFields },
update,
})
}
}
Expand Down

0 comments on commit b618046

Please sign in to comment.