Skip to content

Commit

Permalink
Merge pull request #1 from IBM/0.1.1.0b0
Browse files Browse the repository at this point in the history
Release 0.1.1.0
  • Loading branch information
victorterpstra authored Jan 11, 2022
2 parents 5f4e90a + 5c22ccd commit 8982433
Show file tree
Hide file tree
Showing 44 changed files with 7,935 additions and 229 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ mydjangosite/.idea/
# Secrets
my_secrets/
secrets/

# Downloads from Dash App. TODO: move to different folder?
downloads/
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]## [0.1.0.0b6]
## [Unreleased]## [0.1.1.1b0]

## [0.1.1.0] - 2022-01-11
### Changed
- Version bump-up to 0.1.1.0 due to many new features
- DashApp, DoDashApp `debug` property renamed to `dash_debug`
- HomePageEdit and PrepareDataEdit are default main pages
### Added
- HomePage: Scenario duplicate, rename, delete
- DoDashApp.db_echo flag for DB connection debugging
- HomePage: Download scenario as Excel file
- HomePage: Download all scenarios as zip archive
- HomePage: Upload scenarios (from individual .xlsx or multiple in .zip)
- Read and Delete scenario using SQLAlchemy
- Duplicate scenario using SQLAlchemy insert-select

## [0.1.0.0b5] - 2022-01-05
### Changed
Expand Down
16 changes: 16 additions & 0 deletions PyCharmProjectReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# DSE_DO_Dashboard - PyCharm Project setup

## Install environment and dependencies
1. File -> Settings -> Project -> Python Interpreter
Create a new virtual environment
2. Let `requirements.txt` install the dependencies

## Test the dse-do-dashboard package
In the `test` folder, add dashboard tests.
In order for the test to be able to do a regular import, add the `test` folder as a content root / source folder to the project

## Add dependency on dse-do-utils
Add the dse-do-utils root as a source folder to the project
1. File -> Settings -> Project -> Project Structure
2. Add Content Root
This allows us to develop the both packages in combination. Change the dse-do-utils and test in the dse-do-dashboard
6 changes: 3 additions & 3 deletions dse_do_dashboard/dash_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class DashApp(ABC):
def __init__(self, logo_file_name: str = 'IBM.png',
cache_config: Dict = {},
port: int = 8050,
debug: bool = False,
dash_debug: bool = False,
host_env: Optional[HostEnvironment] = None):
self.port = port
self.host_env = host_env
self.debug = debug
self.dash_debug = dash_debug
self.app = self.create_dash_app()

# Margins to layout the header, sidebar and content area:
Expand Down Expand Up @@ -83,7 +83,7 @@ def run_server(self):
DA.run_server()
"""
self.app.run_server(debug=self.debug, port=self.port)
self.app.run_server(debug=self.dash_debug, port=self.port)

def config_cache(self):
self.cache = Cache()
Expand Down
18 changes: 12 additions & 6 deletions dse_do_dashboard/do_dash_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from typing import Dict, List, Optional

import pandas as pd

from dse_do_dashboard.main_pages.home_page_edit import HomePageEdit
from dse_do_dashboard.main_pages.prepare_data_page_edit import PrepareDataPageEdit
from dse_do_utils import DataManager
from dse_do_utils.scenariodbmanager import ScenarioDbManager

Expand Down Expand Up @@ -45,14 +48,15 @@ class DoDashApp(DashApp):
"""
def __init__(self, db_credentials: Dict,
schema: Optional[str] = None,
db_echo: Optional[bool] = False,
logo_file_name: Optional[str] = 'IBM.png',
cache_config: Optional[Dict]= {},
visualization_pages: Optional[List[VisualizationPage]]= [],
database_manager_class=None,
data_manager_class=None,
plotly_manager_class=None,
port: Optional[int] = 8050,
debug: Optional[bool] = False,
dash_debug: Optional[bool] = False,
host_env: Optional[HostEnvironment] = None
):
"""Create a Dashboard app.
Expand All @@ -70,13 +74,14 @@ def __init__(self, db_credentials: Dict,
:param plotly_manager_class: class of the PlotlyManager.
Either specify the `data_manager_class` and the `plotly_manager_class` or override the method `get_plotly_manager`
:param port: Port for DashApp. Default = 8050.
:param debug: If true, runs dash app server in debug mode.
:param dash_debug: If true, runs dash app server in debug mode.
:param host_env: If HostEnvironment.CPD402, will use the ws_applications import make_link to
generate a requests_pathname_prefix for the Dash app. For use with custom environment in CPD v4.0.02.
The alternative (None of HostEnvironment.Local) runs the Dash app regularly.
"""
self.db_credentials = db_credentials
self.schema = schema
self.db_echo = db_echo
self.database_manager_class = database_manager_class
# assert issubclass(self.database_manager_class, ScenarioDbManager)
self.dbm = self.create_database_manager_instance()
Expand Down Expand Up @@ -118,15 +123,15 @@ def __init__(self, db_credentials: Dict,
self.read_scenario_table_from_db_callback = None # For Flask caching
self.read_scenarios_table_from_db_callback = None # For Flask caching

super().__init__(logo_file_name=logo_file_name, cache_config=cache_config, port=port, debug=debug, host_env=host_env)
super().__init__(logo_file_name=logo_file_name, cache_config=cache_config, port=port, dash_debug=dash_debug, host_env=host_env)

def create_database_manager_instance(self) -> ScenarioDbManager:
"""Create an instance of a ScenarioDbManager.
The default implementation uses the database_manager_class from the constructor.
Optionally, override this method."""
if self.database_manager_class is not None and self.db_credentials is not None:
print(f"Connecting to DB2 at {self.db_credentials['host']}")
dbm = self.database_manager_class(credentials=self.db_credentials, schema=self.schema, echo=False)
dbm = self.database_manager_class(credentials=self.db_credentials, schema=self.schema, echo=self.db_echo)
else:
print("Error: either specifiy `database_manager_class`, `db_credentials` and `schema`, or override `create_database_manager_instance`.")
return dbm
Expand All @@ -136,8 +141,8 @@ def create_main_pages(self) -> List[MainPage]:
Can be overridden to replace by subclasses (not typical).
"""
main_pages = [
HomePage(self),
PrepareDataPage(self),
HomePageEdit(self),
PrepareDataPageEdit(self),
RunModelPage(self),
ExploreSolutionPage(self),
VisualizationTabsPage(self)
Expand Down Expand Up @@ -449,6 +454,7 @@ def get_table_by_name(self, dm: DataManager,

def get_table_schema(self, table_name: str) -> Optional[ScenarioTableSchema]:
table_schema = None
# print(f"get_table_schema - {self.table_schemas}")
if self.table_schemas is not None and table_name in self.table_schemas:
table_schema = self.table_schemas[table_name]
return table_schema
Expand Down
Loading

0 comments on commit 8982433

Please sign in to comment.