Skip to content
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

WIP: Feat / 48 Configurable Jbrowse Wrapper #197

Open
wants to merge 10 commits into
base: feat/jbrowsemvp-arranger3
Choose a base branch
from

Conversation

demariadaniel
Copy link

@demariadaniel demariadaniel commented Apr 8, 2024

https://app.zenhub.com/workspaces/overture-stack-5d2e058ff67cc800011fee6b/issues/gh/overture-stack/dms-jbrowse-components/48

  • Separates code for default file query handling and dynamic env queries
  • Code for env queries is based off of Table Data query; example is in env.test. This query will return data from Arranger.
  • Moves logic into defined functions + util files

const arrangerFetcher = createArrangerFetcher({});

const fileQuery = `file {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be its own json file

}
}
}
${dataQuery}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use interchangeable query bodies

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great start! not depending on the hard coded query, the root of the issue.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK great, wasn't sure if we were simply 'swapping queries' or if we were potentially retrieving data from a source other than Arranger

Comment on lines 150 to 152
const isDefaultDataModel = !NEXT_PUBLIC_JBROWSE_DATA_MODEL ? true : false;
// TODO: Handle Alternate Data Model
const nodes = isDefaultDataModel ? data.file?.hits?.edges : [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what you're doing here, and the syntax can be simplified further.
right now it reads as isDefaultMode is true if the condition (without the env var being set) is true, and false if the condition is false. without the "true if true, false if false" redundancy, you could just do const isDefaultDataModel = !NEXT_PUBLIC_JBROWSE_DATA_MODEL;

That said, when the data model is not the default one, then you're not using the data at all, right?
the code in line 155+ will be filtering over an empty array every time the data model is not the default one.
Thinking there's more to be done in this part of the code to account for that model change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's why I added the TODO at 151. For now I don't have an example definition for alternate data models, so there's no code to write. Will simplify the conditional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what I mean here is the params in 158-162, etc. will change if the data model is different.
I have a feeling this whole thing will have to be refactored into using env variables to determine the "json path" for file size, and for file type, and so on.

see https://www.npmjs.com/package/jsonpath

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly -- this is why I kept the empty array for now and have not updated lines 151+ onward. Data model is ambiguous so we need something to help navigate various data models. JSON Path seems like it might be the perfect tool.

@demariadaniel demariadaniel changed the title WIP: Feat/48 configurable jbrowse wrapper Feat / 48 Configurable Jbrowse Wrapper Apr 11, 2024
const nodes = isDefaultDataModel
? data.file?.hits?.edges
: jsonpath
.query(data, '$..edges')[0]
Copy link
Author

@demariadaniel demariadaniel Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given Jbrowse compatibility filter and file mapping requires specific properties, you kind of have to know what the input query is going to be.

Here I am querying edges[0] because it allows me to get all the nodes and then map them. I might be able to simplify this a bit by querying nodes, but you still need that identifier to know the name of your objects.

If your query doesn't have edges (or nodes), it won't work. The query can't be completely ambiguous.

We might be able to do a .find() to get an array of all objects with the given fields we need as an alternate solution
cc: @justincorrigible

}
}
}
// TODO: Add Filters back in ($filters:JSON)
Copy link
Author

@demariadaniel demariadaniel Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not sure how variables will work in this format. Adding $filters to the env variable causes gql validation errors; adding it to the jbrowseinput query string causes a filters is unused error.
cc: @justincorrigible

score: '',
sort: [{ fieldName: 'analysis_id', order: 'asc' }],
sqon: null,
},
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not be appropriate for all queries as well so this is another piece to revisit

Comment on lines +100 to +107
node: {
data_type: string;
object_id: string;
name: string;
size: number;
fileType: string;
file_access: string;
};
Copy link
Member

@justincorrigible justincorrigible Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the names in this properties cannot be guaranteed in the input model
e.g. fileType, vs file_type, vs file.type

@@ -104,6 +104,27 @@ export const jbrowseFileMetadataQuery = `
}
`;

export const fileQuery = `file {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking it would be useful to call this defaultArrangerFileQuery or something like that to make it more declarative

@demariadaniel demariadaniel changed the title Feat / 48 Configurable Jbrowse Wrapper WIP: Feat / 48 Configurable Jbrowse Wrapper May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants