Spaces:
Running
Running
Download check.py from HuggingFaceBio/carbon-a-release: direct link, hf CLI and curl.
- Browser
- Download file 2.87 kB
-
https://huggingface.co/spaces/HuggingFaceBio/carbon-a-release/resolve/main/check.py
- Command line
-
hf download hf://spaces/HuggingFaceBio/carbon-a-release/check.py
-
curl -L -o check.py https://huggingface.co/spaces/HuggingFaceBio/carbon-a-release/resolve/main/check.py
2.87 kB
| from pathlib import Path | |
| import sys,json,time | |
| sys.path.insert(0,'/home/node/local/carbon-a-render/python') | |
| from playwright.sync_api import sync_playwright | |
| ROOT=Path(__file__).parent | |
| with sync_playwright() as p: | |
| b=p.chromium.launch(executable_path='/opt/pw-browsers/chromium_headless_shell-1234/chrome-headless-shell-linux64/chrome-headless-shell',headless=True,args=['--no-sandbox','--enable-webgl','--use-gl=angle','--use-angle=swiftshader','--enable-unsafe-swiftshader']) | |
| page=b.new_page(viewport={'width':1500,'height':1050},device_scale_factor=1) | |
| errors=[];page.on('pageerror',lambda e:errors.append(str(e))) | |
| start=time.time();page.goto((ROOT/'index.html').as_uri());page.wait_for_function('window.POC && !document.querySelector("#loading")',timeout=90000);page.wait_for_timeout(1000) | |
| print('loaded',round(time.time()-start,2),page.evaluate('({assemblies:POC.assemblies,vertices:POC.vertices,prior:POC.prior,refseq:POC.refseq})'),flush=True) | |
| page.screenshot(path=str(ROOT/'overview.png')) | |
| page.locator('#detail').click();page.wait_for_timeout(800);page.screenshot(path=str(ROOT/'detail.png')) | |
| page.locator('#sel-close').click(); bounds=page.locator('#stage').bounding_box(); page.mouse.click(bounds['x']+bounds['width']/2,bounds['y']+bounds['height']/2); assert page.locator('#sel-id').inner_text()=='GCA_000001405.29'; page.locator('#sel-loci').click();page.wait_for_timeout(200);page.screenshot(path=str(ROOT/'genes.png'));page.locator('#gene-close').click() | |
| page.locator('#reset').click();page.locator('#scope').select_option('1');page.locator('#existing-only').check();page.wait_for_timeout(500);page.screenshot(path=str(ROOT/'refseq.png')) | |
| page.locator('#search').fill('Drosophila melanogaster');page.wait_for_timeout(100);print('search results',page.locator('#results button').count(),flush=True);page.locator('#results button').first.click();print('selected',page.locator('#sel-id').inner_text(),flush=True) | |
| assert page.locator('#blue-count').inner_text()=='1,323' | |
| assert page.evaluate('POC.assemblies')==33588 | |
| assert page.evaluate('POC.prior')==4238 | |
| page.locator('#reset').click(); bounds=page.locator('#stage').bounding_box(); page.mouse.move(bounds['x']+bounds['width']*.65,bounds['y']+bounds['height']*.6); page.mouse.wheel(0,-600); page.wait_for_timeout(250); assert page.evaluate('POC.zoom')>1 | |
| page.mouse.down(); page.mouse.move(bounds['x']+bounds['width']*.65+40,bounds['y']+bounds['height']*.6+30,steps=3); page.mouse.up(); page.wait_for_timeout(100) | |
| assert page.evaluate('POC.leaves.every(a => a.lineage[0].id===2759)') | |
| assert page.evaluate('new Set(POC.leaves.map(a=>a.accession)).size')==33588 | |
| assert not errors,errors | |
| page.set_viewport_size({'width':430,'height':932});page.locator('#reset').click();page.wait_for_timeout(300);page.screenshot(path=str(ROOT/'mobile.png'),full_page=True) | |
| print('errors',errors,flush=True);b.close() | |