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

[REFATORAÇÃO] SOLID e Clean Code em scheduler.py #31

Open
wants to merge 150 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
241c2c1
upgrading streamlit
guilhermedelyra Oct 5, 2020
c96f7c4
changing return type of some functions from numpy.float64 to float
Oct 5, 2020
81b159c
Merge branch 'master' into i13_update_streamlit
Oct 6, 2020
3a2aa2b
Merge pull request #5 from GCES-Pydemic/i13_update_streamlit
guilhermedelyra Oct 6, 2020
0703e83
Update issue templates
Oct 6, 2020
fb09752
Merge remote-tracking branch 'upstream/master'
RCristyan Oct 8, 2020
d7ba29c
App Pydemic-UI API explorer adapted to class.
RCristyan Oct 8, 2020
ee7f1fa
pycodestyle fix.
RCristyan Oct 8, 2020
01f0749
Update issue templates
Oct 8, 2020
347e1e6
Merge remote-tracking branch 'upstream/master' into upstream
Oct 8, 2020
dc06ea9
Merge pull request #20 from GCES-Pydemic/add_bug_report_template
Oct 8, 2020
c4b1738
Merge branch 'master' into adding-issue-template
Oct 8, 2020
a6bfa47
Merge pull request #6 from GCES-Pydemic/adding-issue-template
Oct 8, 2020
eefc5ff
Merge branch 'master' into upstream
Oct 8, 2020
d698f8b
Merge pull request #21 from GCES-Pydemic/upstream
Oct 8, 2020
3a7c915
Add some development useful commands to readme
WillAllmeida Oct 8, 2020
63dce28
Merge branch 'master' of https://github.com/GCES-Pydemic/pydemic-ui
RCristyan Oct 10, 2020
6687e44
projections_br app adapted to class.
RCristyan Oct 10, 2020
b85c992
Added growth factor graph.
RCristyan Oct 10, 2020
cc65e47
Added 2 graphs and method run_models.
RCristyan Oct 10, 2020
18a2461
Added graphs and info about deaths and ICU overflow.
RCristyan Oct 10, 2020
5d10445
pycodestyle fix.
RCristyan Oct 10, 2020
d23940a
#22 - Fixed .rst errors and added 'Development in Docker' subsection
Oct 10, 2020
cdb91f8
hotfixing streamlit version
Oct 10, 2020
65948c5
hotfixing streamlit version
Oct 10, 2020
01c540d
hotfixing streamlit version
Oct 10, 2020
9f65a54
Merge pull request #27 from GCES-Pydemic/hotfix-streamlit
guilhermedelyra Oct 11, 2020
74291bb
Merge branch 'master' into REFACTOR_projections_br_class.py
Oct 11, 2020
dc79d42
Merge branch 'master' into 22-UpdateReadme
Oct 11, 2020
838a981
Merge pull request #23 from GCES-Pydemic/22-UpdateReadme
Oct 11, 2020
b5112fb
Merge branch 'master' into REFACTOR_projections_br_class.py
Oct 11, 2020
42c8eb9
Merge branch 'master' into REFACTOR_api_explorer
Oct 11, 2020
5e73eac
Merge pull request #25 from GCES-Pydemic/REFACTOR_projections_br_clas…
RCristyan Oct 11, 2020
4bd7983
Merge branch 'master' into REFACTOR_api_explorer
RCristyan Oct 11, 2020
7c26e95
Merge pull request #24 from GCES-Pydemic/REFACTOR_api_explorer
RCristyan Oct 11, 2020
1d946c2
Projections app adapted to class
RCristyan Oct 11, 2020
d398c30
Added more methods.
RCristyan Oct 13, 2020
fdea185
Adjustment on method show_outputs.
RCristyan Oct 13, 2020
374f392
Refactoring on method show_outputs.
RCristyan Oct 13, 2020
69d99e7
pycodestyle fix.
RCristyan Oct 13, 2020
989eb59
Refactor calc app
WillAllmeida Oct 13, 2020
5d0a9f2
Fix to pycodestyle smells
WillAllmeida Oct 13, 2020
fbd0de1
Merge pull request #28 from GCES-Pydemic/REFACTOR_projections
WillAllmeida Oct 13, 2020
2141300
Fix to provisory footnote_disclaimer
WillAllmeida Oct 13, 2020
6caad85
Merge branch 'master' into REFACTOR_calc
RCristyan Oct 13, 2020
aacf54f
Merge pull request #30 from GCES-Pydemic/REFACTOR_calc
RCristyan Oct 13, 2020
99f56e3
Update i18n.py
RCristyan Oct 21, 2020
2d6bdcc
hotfixing default language option
Oct 21, 2020
250b5a4
Merge pull request #35 from GCES-Pydemic/HOTFIX-Default-language
Oct 21, 2020
8d0d1f5
Add handling to C.UTF-8 locate
WillAllmeida Oct 22, 2020
4ee34f9
started adding cache and scheduler logic
Oct 22, 2020
d1ac181
Merge pull request #36 from GCES-Pydemic/HOTFIX_footnote-locale
Oct 22, 2020
7771596
Adicionada primeira versão de datetime_to_time()
RCristyan Oct 23, 2020
cc4a12d
fixed wrong docker-compose command on README
RCristyan Oct 23, 2020
c93dc9c
Ajustes na logica da fila de tarefas.
RCristyan Oct 23, 2020
d38eb58
Added custom clock support
RCristyan Oct 23, 2020
127f481
Code refactoring
RCristyan Oct 23, 2020
be55070
Added list_all_tasks() method
RCristyan Oct 24, 2020
059f23e
Implemented daily scheduling logic
RCristyan Oct 24, 2020
839a559
Implemented weekly scheduling logic
RCristyan Oct 25, 2020
6a96bfb
Implemented monthly scheduling logic
RCristyan Oct 26, 2020
05666eb
Changed clock tick logic
RCristyan Oct 26, 2020
ab73c4f
Added a basic scheduler test
RCristyan Oct 26, 2020
96daac8
Merge pull request #37 from GCES-Pydemic/HOTFIX-Readme
Oct 27, 2020
539dc98
rename scheduler module
Oct 27, 2020
41589df
fixing function call inexpired ttl case
Oct 27, 2020
1b03a05
Add HTML Report class with initial handlers
WillAllmeida Oct 27, 2020
25a390a
Add experimental app to test htmlreport
WillAllmeida Oct 27, 2020
d0d96e0
Add header handler to htmlreport
WillAllmeida Oct 28, 2020
0d49dba
Add subheader and info handler to htmlreport
WillAllmeida Oct 29, 2020
01937ef
Implemented stop, pause and resume methods for scheduler
RCristyan Oct 29, 2020
d78a257
Implemented scheduler pause and stop tests.
RCristyan Oct 29, 2020
ce1bcfb
Added daily schedule test
RCristyan Oct 31, 2020
12f7061
Implemented thread termination.
RCristyan Oct 31, 2020
5175bd4
Small adjustment on daily schedule test
RCristyan Oct 31, 2020
4932811
Added weekly schedule test.
RCristyan Nov 3, 2020
1d276fa
Added monthly schedule test.
RCristyan Nov 3, 2020
740f5b8
finishing fasttrack cache with ttl and added scheduled cache updates
Nov 5, 2020
704a620
fixing linting
Nov 5, 2020
d1fc755
Fixed method misspell.
RCristyan Nov 7, 2020
c1c15d6
Add handler to simple table
WillAllmeida Nov 9, 2020
baf63c5
Add handler to dataframe with size limits
WillAllmeida Nov 9, 2020
b0ac68b
Remove bad smells from pycodestyle
WillAllmeida Nov 9, 2020
5a42b51
Added an optional warning on force reload button.
RCristyan Nov 9, 2020
d65d3e6
pycodestyle fix.
RCristyan Nov 9, 2020
76ffb30
trying to fix CI hanging
Nov 9, 2020
5f5f71e
Merge branch 'hotfix/CI_test' into feature/ForceReloadWarning
Nov 9, 2020
f67dc0e
Merge branch 'master' into feature/ForceReloadWarning
Nov 9, 2020
6fbac67
Merge pull request #38 from GCES-Pydemic/feature/ForceReloadWarning
Nov 9, 2020
6afcca2
creating mocks for button element
Nov 11, 2020
6effdaa
creating code coverage CI step
Nov 12, 2020
f55427a
hotfixing CI file
Nov 12, 2020
cfc8860
hotfixing CI file
Nov 12, 2020
95f5e95
hotfixing CI file
Nov 12, 2020
001e75a
hotfixing CI file
Nov 12, 2020
96f6cbc
hotfixing CI file
Nov 12, 2020
53ae728
hotfixing CI file
Nov 12, 2020
eae2ec9
hotfixing CI file
Nov 12, 2020
7ee12a6
hotfixing CI file
Nov 12, 2020
05391e5
hotfixing CI file
Nov 12, 2020
d55d92a
hotfixing CI file
Nov 12, 2020
4374e19
add code coverage badge readme
Nov 12, 2020
7df06f7
Merge pull request #40 from GCES-Pydemic/feature/CI_codecov
Nov 12, 2020
129a24b
adding line chart handler
guilhermedelyra Nov 15, 2020
26ceec6
adding area chart handler
guilhermedelyra Nov 15, 2020
20fc177
adding bar chart handler
guilhermedelyra Nov 15, 2020
34fe01a
adding dummy pdf generator
guilhermedelyra Nov 15, 2020
47f3ab5
adding dependencies to dockerfile/pyproject.toml
guilhermedelyra Nov 15, 2020
e0e3177
Merge branch 'Feature/HTMLReport' of https://github.com/GCES-Pydemic/…
guilhermedelyra Nov 15, 2020
dc72c60
Fixing minor bad smells
WillAllmeida Nov 15, 2020
55aaa81
Fixing requested liting issues
WillAllmeida Nov 18, 2020
02669f3
Merge branch 'master' into Feature/HTMLReport
Nov 18, 2020
a31f666
Small refactoring and added comments in some methods.
RCristyan Nov 19, 2020
6f40b98
Some clean code refactoring.
RCristyan Nov 19, 2020
15eeb9e
Variable renaming.
RCristyan Nov 19, 2020
01f91c1
Added handle_explore_option() method.
RCristyan Nov 21, 2020
6b77bf9
Variable renaming in explore_object_attribute() method.
RCristyan Nov 21, 2020
3de48b0
Small refactoring in explore_object() method.
RCristyan Nov 21, 2020
e09c417
Added auxiliary explore_function_output() method.
RCristyan Nov 21, 2020
a66b05d
Refactoring in select_method() method.
RCristyan Nov 21, 2020
5c4401c
Refactoring in select_arguments() method.
RCristyan Nov 21, 2020
7bdaad2
Applying clean code practices to scenarios1 class
WillAllmeida Nov 24, 2020
3907a53
Add private method notation
WillAllmeida Nov 24, 2020
e28c3d2
Add SRP application
WillAllmeida Nov 24, 2020
ca2dc63
Add get_regions to scenarios data class
WillAllmeida Nov 24, 2020
a6d488b
Merge pull request #41 from GCES-Pydemic/Feature/HTMLReport
Nov 24, 2020
46e88aa
Merge branch 'master' of https://github.com/GCES-Pydemic/pydemic-ui i…
RCristyan Nov 24, 2020
c49f1aa
Merge branch 'master' of https://github.com/GCES-Pydemic/pydemic-ui i…
RCristyan Nov 24, 2020
7e6b16f
applying solid principles to calc_class.py
guilhermedelyra Nov 25, 2020
db01b46
Improvements to Scenarios2 Class
WillAllmeida Nov 25, 2020
77e0975
Refactoring cache to use Class [single-responsibiliy principle]
guilhermedelyra Nov 25, 2020
4a8b496
Fixing pycodestyle bad smells
WillAllmeida Nov 25, 2020
f9deb37
:construction_worker: fixing linting errors
guilhermedelyra Nov 25, 2020
7f2623b
hotfixing info.py
guilhermedelyra Nov 25, 2020
8f4b35d
hotfixing cache.py imports
guilhermedelyra Nov 25, 2020
8bb3ce9
Merge pull request #42 from GCES-Pydemic/refactoring/SOLID-CleanCode/…
Nov 26, 2020
1cbb6e8
Add cache time variable
WillAllmeida Nov 26, 2020
4f9fc06
Merge branch 'master' into refactoring/SOLID-CleanCode/calc_class
guilhermedelyra Dec 7, 2020
b6d6bc2
Merge branch 'master' into REFACTOR_SOLID_CLEAN_CODE_api_explorer_class
guilhermedelyra Dec 7, 2020
3d2a6f6
Merge branch 'master' into REFACTOR_SOLID_CLEAN_CODE_scheduler
guilhermedelyra Dec 7, 2020
36f8489
Merge branch 'master' into Refactor-Scenarios_Apps
guilhermedelyra Dec 7, 2020
d2a2f51
Merge pull request #43 from GCES-Pydemic/refactoring/SOLID-CleanCode/…
RCristyan Dec 7, 2020
24376d8
Merge branch 'master' into REFACTOR_SOLID_CLEAN_CODE_api_explorer_class
guilhermedelyra Dec 7, 2020
3b97cd8
Merge branch 'master' into Refactor-Scenarios_Apps
guilhermedelyra Dec 7, 2020
8bbd780
Merge branch 'master' into REFACTOR_SOLID_CLEAN_CODE_scheduler
guilhermedelyra Dec 7, 2020
35d0ac7
Merge pull request #44 from GCES-Pydemic/REFACTOR_SOLID_CLEAN_CODE_ap…
RCristyan Dec 7, 2020
bea8759
Merge branch 'master' into Refactor-Scenarios_Apps
guilhermedelyra Dec 7, 2020
eb3d5f5
Merge branch 'master' into REFACTOR_SOLID_CLEAN_CODE_scheduler
guilhermedelyra Dec 7, 2020
ef2dceb
Merge pull request #47 from GCES-Pydemic/Refactor-Scenarios_Apps
guilhermedelyra Dec 7, 2020
3bf675f
Merge branch 'master' into REFACTOR_SOLID_CLEAN_CODE_scheduler
guilhermedelyra Dec 7, 2020
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
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: Issue Template
about: General Issue template
title: Give your issue a nice descriptive name
labels: ''
assignees: ''

---

## Description
Describe your issue here. Write clearly to make yourself understood :smiley:

### Cheklist (optional)
- [ ] item 1
- [ ] item 2
11 changes: 5 additions & 6 deletions .github/workflows/pydemic-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Service
run: |
docker-compose up -d pydemic-ui

- name: Lint with pycodestyle
run: |
docker-compose exec -T pydemic-ui pycodestyle
docker-compose run pydemic-ui pycodestyle
- name: Test with pytest
run: |
docker-compose exec -T pydemic-ui pytest
docker-compose run pydemic-ui pytest --cov=./ --cov-report=xml
- name: Code Coverage
run: |
bash <(curl https://codecov.io/bash)
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ htmlcov/
deploy/inventory.yml
deploy-pydemic-ui/inventory.yml
.python-version

.tmp/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV PYTHONUNBUFFERED=1 \
COPY assets/locale.gen /etc/locale.gen

RUN apt update && \
apt install -y git locales && \
apt install -y git locales wkhtmltopdf && \
locale-gen

WORKDIR /app
Expand Down
35 changes: 34 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
==========
Pydemic UI
==========
|Build Badge|
|Build Badge| |Coverage Badge|

.. |Build Badge| image:: https://img.shields.io/github/workflow/status/GCES-Pydemic/pydemic-ui/Pydemic%20CI?logo=github&style=flat-square
:alt: GitHub Workflow Status

.. |Coverage Badge| image:: https://codecov.io/gh/GCES-Pydemic/pydemic-ui/branch/master/graph/badge.svg
:alt: Code Coverage
:target: https://codecov.io/gh/GCES-Pydemic/pydemic-ui


A set of streamlit apps and utilities used in creating the UI for Pydemic apps.
Expand All @@ -29,3 +33,32 @@ specifying the desired app::

Currently, only the calc app is available, but other apps should arrive soon. For more
options, execute it with the "--help" flag.

Development Usage
=================

Install the dependencies using the command bellow. More details are available on flit documentation(https://flit.readthedocs.io/en/latest/cmdline.html)::

$ flit install -s --user

After the installation is completed, run streamlit apps using invoke::

$ inv run

Development in Docker
=====================

The project has been containerized in Docker in order to speed up the setup of the development environment. You can run the containers using the methods below:

Docker Compose
--------------

You can run the project using Docker Compose by having it installed and running the following command::

$ docker-compose up pydemic-ui

VSCode Remote - Containers
--------------------------

The project has a ``devcontainer.json``, so you can open it inside a container using Visual Studio Code by having the "Remote - Containers" ``ms-vscode-remote.remote-containers`` extension installed.

25 changes: 25 additions & 0 deletions experiments/cache_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import joblib
import time
from pydemic_ui.scheduler import scheduler
from pydemic_ui.cache import Cache

path = ".tmp/"
memory = joblib.Memory(path)


@Cache.TTL(10, True, 30)
@joblib.wrap_non_picklable_objects
def fn(x):
time.sleep(2.4)
return x * 2


@Cache.Schedule('daily', time=...)
@joblib.wrap_non_picklable_objects
def fn1(x):
time.sleep(2.4)
return x * 2


fn(5)
fn1(5)
49 changes: 49 additions & 0 deletions experiments/htmlrender.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from pydemic_ui.st_logger import StLogger
import streamlit
from pydemic_ui.html_report import HtmlReport
import pandas as pd
import numpy as np
import pdfkit

st = StLogger()
report = HtmlReport()

st.title("Hello World!")
st.text("This is a text!")
st.error("This is an error")
st.header("This is a header")
st.info("This is info")
st.subheader("This is a subheader")
st.button("This is a button")
df = pd.DataFrame(np.random.randn(10, 5), columns=("col %d" % i for i in range(5)))

st.table(df)
st.dataframe(df, 100, 250)

# line chart
chart_data = pd.DataFrame(
np.random.randn(30, 3),
columns=['a', 'b', 'c'])
st.line_chart(chart_data)

# area chart
chart_data = pd.DataFrame(
np.random.randn(40, 3),
columns=['a', 'b', 'c'])
st.area_chart(chart_data)

# bar chart
chart_data = pd.DataFrame(
np.random.randn(50, 3),
columns=['a', 'b', 'c'])
st.bar_chart(chart_data)

st(streamlit)

streamlit.header("Producing report...")
html = report.render(st)

pdfkit.from_string('<html><body>' + html + '</body></html>', 'out.pdf')

streamlit.text(html)
streamlit.subheader("This is a subheader")
Binary file added out.pdf
Binary file not shown.
Loading