Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridging third party HTML5 charts #97

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/covidify/chart_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from __future__ import annotations
from abc import ABC, abstractmethod


class ChartView:
#abstraction

def __init__(self, InterfaceResource: InterfaceResource) -> None:
self.InterfaceResource = InterfaceResource

def operation(self) -> str:
return (f"ChartView: Base operation with:\n"
f"{self.InterfaceResource.operation_InterfaceResource()}")


class LineChart(ChartView):
#concrete abstraction

def operation(self) -> str:
return (f"LineChart: Extended operation with:\n"
f"{self.InterfaceResource.operation_InterfaceResource()}")


class InterfaceResource(ABC):
#implementation

@abstractmethod
def operation_InterfaceResource(self) -> str:
pass


#concrete implementation
class DataFeedResourceA(InterfaceResource):
def operation_InterfaceResource(self) -> str:
return "DataFeedResourceA: Here's the result on the platform A."


class DataFeedResourceB(InterfaceResource):
def operation_InterfaceResource(self) -> str:
return "DataFeedResourceB: Here's the result on the platform B."


def client_side(ChartView: ChartView) -> None:


print(ChartView.operation(), end="")



if __name__ == "__main__":


InterfaceResource = DataFeedResourceA()
ChartView = ChartView(InterfaceResource)
client_side(ChartView)

print("\n")

InterfaceResource = DataFeedResourceB()
ChartView = LineChart(InterfaceResource)
client_side(ChartView)
93 changes: 51 additions & 42 deletions src/covidify/config.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
import os

#
# CLI
#
SCRIPT = '/pipeline.sh'
LIST_SCRIPT = '/pipeline.sh'


#
# DATA PREP
#
REPO = 'https://github.com/CSSEGISandData/COVID-19.git'
TMP_FOLDER = '/tmp/corona/'
TMP_GIT = os.path.join(TMP_FOLDER, REPO.split('/')[-1].split('.')[0])
DATA = os.path.join(TMP_GIT, 'csse_covid_19_data', 'csse_covid_19_daily_reports')
LOG_TOP_N_COUNTRIES = 10


#
# FORECASTING
#
DAYS_IN_FUTURE = 10 # Amount of days you want to forecast into future
PERC_SPLIT = 0.95 # Train / test split for forecasting model.

#
# DATA VISUALIZATION
#
FIG_SIZE = (14,10)


#Github cols
KEEP_COLS = ['country',
'province',
'confirmed',
'deaths',
'recovered',
'date',
'datetime',
'file_date']

NUMERIC_COLS = ['confirmed',
'deaths',
'recovered']
class SingletonConfig(object):
_instance = {}
"""docstring for SingletonConfig"""
def __call__(sngl, *args, **kwargs):
if sngl not in sngl._instance:
cls._instance[sngl] = super(SingletonConfig, sngl).__call__(*args, **kwargs)
return sngl._instance[sngl]

#
# CLI
#
SCRIPT = '/pipeline.sh'
LIST_SCRIPT = '/pipeline.sh'


#
# DATA PREP
#
REPO = 'https://github.com/CSSEGISandData/COVID-19.git'
TMP_FOLDER = '/tmp/corona/'
TMP_GIT = os.path.join(TMP_FOLDER, REPO.split('/')[-1].split('.')[0])
DATA = os.path.join(TMP_GIT, 'csse_covid_19_data', 'csse_covid_19_daily_reports')
LOG_TOP_N_COUNTRIES = 10


#
# FORECASTING
#
DAYS_IN_FUTURE = 10 # Amount of days you want to forecast into future
PERC_SPLIT = 0.95 # Train / test split for forecasting model.

#
# DATA VISUALIZATION
#
FIG_SIZE = (14,10)


#Github cols
KEEP_COLS = ['country',
'province',
'confirmed',
'deaths',
'recovered',
'date',
'datetime',
'file_date']

NUMERIC_COLS = ['confirmed',
'deaths',
'recovered']

Loading