stjude / proteinpaint

Data visualization and analysis framework focused on phenotype-molecular data integration at cohort level.
https://proteinpaint.stjude.org/
Other
18 stars 5 forks source link

Improved typing for `hicdata` and `hicgenome` routes #1746

Closed creilly8 closed 3 months ago

creilly8 commented 3 months ago

Description

Addresses the concern about the hicdata and hicgenome routes using the same types. @siosonel, please let me know if this addresses the concerns about the types. All tests pass on my local.

Changes:

  1. Separated types between the hicdata and hicgenome routes.
  2. Added examples to both routes
  3. Validation type for file v. url

Test with:

  1. Demo whole genome file
  2. Remote whole genome file
  3. Examples: App drawer examples
  4. Any hic file from http://localhost:3000/url.html

Checklist

Check each task that has been performed or verified to be not applicable.

siosonel commented 3 months ago

@creilly8 Your code is correct, the issue is really with the augen type checker code generator. If I run npx tsc from the server dir, I see errors like below. The augen code makes assumptions, that each file under server/route will have a similarly named file under server/shared/types/routes dir. So, reusing hic.ts to define request, response types for 2 different routes breaks this assumption. I could either (a) fix augen, or (b) temporarily separate types/routes/hic.ts into types/routes/hicdata.ts and types/routes/hicgenome.ts (and fix augen later).

$ npx tsc
shared/checkers-raw/index.ts:10:10 - error TS2305: Module '"../types/routes/hicdata.ts"' has no exported member 'HicdataRequest'.

10 import { HicdataRequest, HicdataResponse } from '../types/routes/hicdata.ts'
            ~~~~~~~~~~~~~~

shared/checkers-raw/index.ts:10:26 - error TS2305: Module '"../types/routes/hicdata.ts"' has no exported member 'HicdataResponse'.

10 import { HicdataRequest, HicdataResponse } from '../types/routes/hicdata.ts'
                            ~~~~~~~~~~~~~~~

shared/checkers-raw/index.ts:11:53 - error TS2307: Cannot find module '../types/routes/hicgenome.ts' or its corresponding type declarations.

11 import { HicGenomeRequest, HicGenomeResponse } from '../types/routes/hicgenome.ts'
                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

shared/checkers/index.ts:10:10 - error TS2305: Module '"../types/routes/hicdata.js"' has no exported member 'HicdataRequest'.

10 import { HicdataRequest, HicdataResponse } from "../types/routes/hicdata.js";
            ~~~~~~~~~~~~~~

shared/checkers/index.ts:10:26 - error TS2305: Module '"../types/routes/hicdata.js"' has no exported member 'HicdataResponse'.

10 import { HicdataRequest, HicdataResponse } from "../types/routes/hicdata.js";
                            ~~~~~~~~~~~~~~~

Found 5 errors in 2 files.

Errors  Files
     3  shared/checkers-raw/index.ts:10
       2  shared/checkers/index.ts:10
creilly8 commented 3 months ago

@creilly8 Your code is correct, the issue is really with the augen type checker code generator. If I run npx tsc from the server dir, I see errors like below. The augen code makes assumptions, that each file under server/route will have a similarly named file under server/shared/types/routes dir. So, reusing hic.ts to define request, response types for 2 different routes breaks this assumption. I could either (a) fix augen, or (b) temporarily separate types/routes/hic.ts into types/routes/hicdata.ts and types/routes/hicgenome.ts (and fix augen later).

$ npx tsc
shared/checkers-raw/index.ts:10:10 - error TS2305: Module '"../types/routes/hicdata.ts"' has no exported member 'HicdataRequest'.

10 import { HicdataRequest, HicdataResponse } from '../types/routes/hicdata.ts'
            ~~~~~~~~~~~~~~

shared/checkers-raw/index.ts:10:26 - error TS2305: Module '"../types/routes/hicdata.ts"' has no exported member 'HicdataResponse'.

10 import { HicdataRequest, HicdataResponse } from '../types/routes/hicdata.ts'
                            ~~~~~~~~~~~~~~~

shared/checkers-raw/index.ts:11:53 - error TS2307: Cannot find module '../types/routes/hicgenome.ts' or its corresponding type declarations.

11 import { HicGenomeRequest, HicGenomeResponse } from '../types/routes/hicgenome.ts'
                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

shared/checkers/index.ts:10:10 - error TS2305: Module '"../types/routes/hicdata.js"' has no exported member 'HicdataRequest'.

10 import { HicdataRequest, HicdataResponse } from "../types/routes/hicdata.js";
            ~~~~~~~~~~~~~~

shared/checkers/index.ts:10:26 - error TS2305: Module '"../types/routes/hicdata.js"' has no exported member 'HicdataResponse'.

10 import { HicdataRequest, HicdataResponse } from "../types/routes/hicdata.js";
                            ~~~~~~~~~~~~~~~

Found 5 errors in 2 files.

Errors  Files
     3  shared/checkers-raw/index.ts:10
       2  shared/checkers/index.ts:10

I see. Thanks for letting me know. I will split into two files so augen can be fixed when it's convenient.