Skip to content

Epic Branch Final Step: Merge Epic Branch into Staging#167

Merged
bdls-jamal merged 64 commits intostagingfrom
EpicBranch-routing
Jul 18, 2025
Merged

Epic Branch Final Step: Merge Epic Branch into Staging#167
bdls-jamal merged 64 commits intostagingfrom
EpicBranch-routing

Conversation

@bdls-jamal
Copy link
Copy Markdown
Collaborator

This branch should have all of the following updates:

  1. Navigator view updated with routing changes
  2. Interactions view updated with routing changes
  3. All views available in the routing branch modified to handle loading image/page differently

@bdls-jamal bdls-jamal requested review from VinLau and Yukthiw July 10, 2025 18:08
@@ -0,0 +1,113 @@
import { z, ZodTypeAny } from 'zod'
Copy link
Copy Markdown
Collaborator

@Yukthiw Yukthiw Jul 11, 2025

Choose a reason for hiding this comment

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

I'll write some docstrings for these functions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Perfect

loadingAmount={loadAmount}
gene={geneticElement}
view={ChromosomeViewerObject}
error={ViewDataError.FAILED_TO_LOAD}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
error={ViewDataError.FAILED_TO_LOAD}
error={error}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will always show the error screen instead of loading, I think the best thing to do here is pass the error value in, however LoadingState expects a ViewDataError so we need to make the changes that I suggested above.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Another way is to just have a separate if condition for when theres an error (this is how the other views do it) which works as well and might be simpler for now (I think eventually we'll want to do it the first way since that way we can have more flexibility for how the query functions can error out.

Copy link
Copy Markdown
Collaborator

@Yukthiw Yukthiw Jul 11, 2025

Choose a reason for hiding this comment

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

Nvm I see why you did it this way, the issue is that the chromosome loader doesn't error on unsuccesful response. If you can update the ChromosomeViewLoader to do that (see below) and just wrap it in a try-catch so that ViewDataError.FAILED_TO_LOAD is thrown whenever it errors out (like the above suggestion) . Ideally LoadingPage should just GenericError types but that's a future problem

const ChromosomeViewLoader = async (
  gene: GeneticElement | null,
  loadEvent: (progress: number) => void
) => {
  const poplar = false
  const species = poplar ? 'Populus_trichocarpa' : 'Arabidopsis_thaliana'
  const url = `https://bar.utoronto.ca/eplant${
    poplar ? '_poplar' : ''
  }/cgi-bin/chromosomeinfo.cgi?species=${species}`

  const chromosomeViewData: ChromosomeItem[] = await fetch(url)
    .then((response) => {
      if (!response.ok) {
        throw ViewDataError.FAILED_TO_LOAD
      }
      return response.json()
    })
    .then((responseObj: ChromosomesResponseObj) => responseObj['chromosomes'])
  loadEvent(100)
  return {
    viewData: chromosomeViewData,
  }
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've making this change in all the views where applicable but I've noticed now as well that when no gene is selected yet all the views(aside from navigator and interactions) will hang on the loading page and not display a valid error. This is because there are no checks for !geneticElement like there is in nav and interactions. I know you mentioned wanting to simplify all of the checks but this has been my solution thus far:

if (!geneticElement) {
    return (
      <LoadingPage
        loadingAmount={loadAmount}
        gene={geneticElement}
        view={GeneInfoViewMetadata}
        error={ViewDataError.UNSUPPORTED_GENE}
      ></LoadingPage>
    )
  }

The reason it is working without this in the nav and interactions is because they check for !geneticElement in their loader functions. Not all the views utilize a loader so I've done it the above way for now. Let me know if I shouldn't do this or if you have another suggestion. I'm just going to commit like this and we can go from there

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This works! Good catch

const handleClose = () => {
setMessageOpen(false)
}
const { data, isLoading, isError, error } = useQuery<ChromosomeViewerData>({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const { data, isLoading, isError, error } = useQuery<ChromosomeViewerData>({
const { data, isLoading, isError, error } = useQuery<ChromosomeViewerData, ViewDataError>({

const { data, isLoading, isError, error } = useQuery<ChromosomeViewerData>({
queryKey: [`chromosome`],
queryFn: async () => {
return ChromosomeViewLoader(geneticElement, setLoadAmount)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return ChromosomeViewLoader(geneticElement, setLoadAmount)
try{
return ChromosomeViewLoader(geneticElement, setLoadAmount)
}catch{
throw ViewDataError.FAILED_TO_LOAD
}

Comment thread Eplant/views/ChromosomeViewer/ChromosomeView.tsx
Comment thread Eplant/views/InteractionsViewer/placeholder.tsx Outdated
Copy link
Copy Markdown
Collaborator

@Yukthiw Yukthiw left a comment

Choose a reason for hiding this comment

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

Overall looks great thanks for all your hard work @bdls-jamal! Added a small comment regarding fixing the Chromosome view loading/error state and also a nitpick on using reactQuery instead of your own cache for the InteractionsView Gene data.

I couldn't test out the interactions and chromosome view due to cors errors but the Navigator View looks great!

@bdls-jamal
Copy link
Copy Markdown
Collaborator Author

@Yukthiw All of the views are implemented with error={ViewDataError.FAILED_TO_LOAD} among the other things you suggested to change in the Chromosome viewer. I think your suggestion to change is for all views doing it this way, correct? I'm going to change all of them and then if you could review that commit that would be awesome

…ggested to fix chromosomeviewer but also matching the changes in other views
Comment thread Eplant/main.tsx Outdated
element: <PlantEFPView></PlantEFPView>,
},
{
path: 'tissue/:geneid?',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

experiment-efp/:geneid? is preferred.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done, will be updated in the next commit

Comment thread Eplant/main.tsx Outdated
element: <NavigatorViewObject></NavigatorViewObject>,
},
{
path: 'interactions-viewer/:geneid?',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

interactions-view/:geneid? to be consistent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done, will be updated in the next commit

query
try {
/** Fetch interaction data */
loadEvent(25) /** Start progress */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Explain this counter @bdls-jamal.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

loadEvent is part of the routing changes to help with determining the loading status/state, if you see cellefp loader example in the tutorial from Yukthi, it shows that we return a loadAmount(setLoadAmount). I believe @Yukthiw might be able to speak more on that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah it just controls the amount that the loadbar fills up when loading data. This was actually already part of how the getInitialData functions worked, I ported over the functionality to the loader functions in the routing change. I think most views just go from 0 -> 100 atm but for visual purposes its nice to have some sort of loading bar progress

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reminder to @VinLau (myself) to work on tooltips

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Uncomment @Yukthiw once we figure out config to work on GH pages?

@bdls-jamal bdls-jamal merged commit eafda36 into staging Jul 18, 2025
4 checks passed
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.

3 participants