This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This takes a lot of time (compute heavy). | |
def blocking_function(q: Q, loop: asyncio.AbstractEventLoop): | |
count = 0 | |
total = 10 | |
future = None | |
while count < total: | |
# Check if cancelled. | |
if q.client.event.is_set(): | |
asyncio.ensure_future(show_cancel(q), loop=loop) | |
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
from asyncio import ensure_future, gather, get_event_loop | |
from h2o_wave import data, site, ui | |
from httpx import AsyncClient | |
# TODO: Fill with yours. | |
GH_TOKEN = '' | |
TWITTER_BEARER_TOKEN = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Render overview cards for every framework. | |
for name, metadata in plot_data['github_data'].items(): | |
latest_release = None | |
if metadata['latestRelease'] != None: | |
latest_release = metadata['latestRelease']['createdAt'] | |
page[f'overview-{name}'] = ui.tall_article_preview_card( | |
box=ui.box('intro', width='25%'), | |
title=name, | |
subtitle=metadata['licenseInfo']['name'], | |
image=metadata['openGraphImageUrl'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetch data. | |
plot_data = collections.defaultdict(list) | |
async with AsyncClient() as client: | |
label_query = 'is:issue label:bug' | |
title_query = 'bug in:title' | |
# Wait until all requests have been fulfilled. | |
await gather( | |
ensure_future(fill_github_data(client, plot_data)), | |
ensure_future(fill_github_issues(client, 'H2O Wave', 'wave', 'h2oai', plot_data, label_query)), | |
ensure_future(fill_github_issues(client, 'Streamlit', 'streamlit', 'streamlit', plot_data, label_query)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def fill_github_issues(client: AsyncClient, framework, repo, org, data, query): | |
query += f' repo:{org}/{repo}' | |
# Use gather to make parallel calls and wait until both are complete. | |
open_issues, closed_issues = await gather( | |
client.get( | |
url=f'https://api.github.com/search/issues', | |
params={'q': f'{query} is:open'}, | |
headers={'Authorization': 'Bearer ' + GH_TOKEN} | |
), | |
client.get( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def main(): | |
# Register page at "/" route. | |
page = site['/'] | |
# Setup layout. | |
page['meta'] = ui.meta_card( | |
box='', | |
title='Wave comparison', | |
layouts=[ | |
ui.layout(breakpoint='xs', zones=[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fetch data. | |
plot_data = collections.defaultdict(list) | |
with Client() as client: | |
label_query = 'is:issue label:bug' | |
title_query = 'bug in:title' | |
fill_github_data(client, plot_data), | |
fill_github_issues(client, 'H2O Wave', 'wave', 'h2oai', plot_data, label_query), | |
fill_github_issues(client, 'Streamlit', 'streamlit', 'streamlit', plot_data, label_query), | |
fill_github_issues(client, 'Plotly Dash', 'dash', 'plotly', plot_data, title_query), | |
fill_github_issues(client, 'R Shiny', 'shiny', 'rstudio', plot_data, 'bug'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fill_github_issues(client, framework, repo, org, data, query): | |
query += f' repo:{org}/{repo}' | |
open_issues = client.get( | |
url=f'https://api.github.com/search/issues', | |
params={'q': f'{query} is:open'}, | |
headers={'Authorization': 'Bearer ' + GH_TOKEN} | |
) | |
closed_issues = client.get( | |
url=f'https://api.github.com/search/issues', | |
params={'q': f'{query} is:closed'}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graphql_query = """ | |
fragment repoFields on Repository { | |
createdAt | |
description | |
forkCount | |
homepageUrl | |
openGraphImageUrl | |
stargazerCount | |
licenseInfo { | |
name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: Fill with yours. | |
GH_TOKEN = '' | |
TWITTER_BEARER_TOKEN = '' |