import hopsworks import pandas as pd import gradio as gr from datetime import datetime today = datetime.now().strftime('%Y-%m-%d') # Get data project = hopsworks.login() fs = project.get_feature_store() dataset_api = project.get_dataset_api() most_positive_fg = fs.get_feature_group(name="articles_most_positive", version=1) most_positive_df = most_positive_fg.read() #most_positive_df = most_positive_df[most_positive_df['pubdate'] == today] most_positive_article = most_positive_df.iloc[-1] # get most recent most positive article (in case today's failed) # Get images dataset_api.download("Resources/images/average_sentiment_timeline.png") dataset_api.download("Resources/images/most_positive_timeline.png") if most_positive_article['pubdate'] == today: # show image generated for today's article try: dataset_api.download("Resources/images/news_image.png") news_img = 'news_image.png' except: news_img = 'https://raw.githubusercontent.com/SamuelHarner/app-images/main/images/delight-news-logo.png?raw=true' else: news_img = 'https://raw.githubusercontent.com/SamuelHarner/app-images/main/images/delight-news-logo.png?raw=true' # Get content news_headline = most_positive_article["title"] news_source = most_positive_article["source_id"] news_description = most_positive_article["description"] news_link = most_positive_article["link"] # Create UI with gr.Blocks(theme=gr.themes.Default(font=[gr.themes.GoogleFont("IBM Plex Mono"), "Arial", "sans-serif"])) as demo: gr.Markdown("