databio / bedhost

API and UI for BEDbase
http://api.bedbase.org
BSD 2-Clause "Simplified" License
2 stars 1 forks source link

simplify the served file path construction? #42

Closed stolarczyk closed 3 years ago

stolarczyk commented 3 years ago

When serving files and images we go up two directories in the path construction:

https://github.com/databio/bedhost/blob/2ff8bd497e9420a6c712538862efd12b5e5be91e/bedhost/routers/api.py#L110-L111

an example image we report is:

{"path": "outputs/bedstat_output/78c0e4753d04b238fc07e4ebe5a02984/GSE105587_ENCFF018NNF_conservative_idr_thresholded_peaks_GRCh38_chrombins.pdf", "title": "Regions distribution over chromosomes", "thumbnail_path": "outputs/bedstat_output/78c0e4753d04b238fc07e4ebe5a02984/GSE105587_ENCFF018NNF_conservative_idr_thresholded_peaks_GRCh38_chrombins.png"}

Therefore, it seems like we could just skip the first two directories in the reported path to simplify the served file path construction.

side note: instead of the literal .. we should use os.pardir()

xuebingjie1990 commented 3 years ago

I think because when the path returned by the endpoints includes '../../' , genome browser would have problem accessing the file for example data.bedbase.org/bigBed_files/some.bigbed would work but data.bedbase.org/outputs/bedstat_output/../../bigbed_files/some.bigBed won't. That's why I made the reported path all relative to data.bedbase.org/ instead data.bedbase.org/outputs/bedstat_output/ or data.bedbase.org/outputs/bedbuncher_output/.

However, I haven't fix the problem that the endpoint url for the bigbed files doesn't work for Genome Browser (still using data.bedbase.org instead of the api url).

xuebingjie1990 commented 3 years ago

I realized I misunderstood your comment. I just fixed the path construction.