algomancy-content 0.3.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,45 @@
1
+ from .backend import (
2
+ PlaceholderSchema,
3
+ PlaceholderETLFactory,
4
+ placeholder_input_config,
5
+ PlaceholderKPI,
6
+ PlaceholderAlgorithm,
7
+ PlaceholderParams,
8
+ )
9
+ from .pages import (
10
+ HomePage,
11
+ DataPage,
12
+ ScenarioPage,
13
+ ComparePage,
14
+ OverviewPage,
15
+ PlaceholderDataPage,
16
+ ShowcaseHomePage,
17
+ StandardHomePage,
18
+ StandardDataPage,
19
+ PlaceholderComparePage,
20
+ PlaceholderScenarioPage,
21
+ StandardOverviewPage,
22
+ )
23
+ from .librarymanager import LibraryManager
24
+
25
+ __all__ = [
26
+ "LibraryManager",
27
+ "HomePage",
28
+ "DataPage",
29
+ "ScenarioPage",
30
+ "ComparePage",
31
+ "OverviewPage",
32
+ "ShowcaseHomePage",
33
+ "StandardHomePage",
34
+ "StandardDataPage",
35
+ "PlaceholderDataPage",
36
+ "PlaceholderComparePage",
37
+ "PlaceholderScenarioPage",
38
+ "StandardOverviewPage",
39
+ "PlaceholderETLFactory",
40
+ "PlaceholderSchema",
41
+ "placeholder_input_config",
42
+ "PlaceholderKPI",
43
+ "PlaceholderAlgorithm",
44
+ "PlaceholderParams",
45
+ ]
@@ -0,0 +1,13 @@
1
+ from .placeholderetlfactory import PlaceholderETLFactory
2
+ from .placeholderinputconfig import PlaceholderSchema, placeholder_input_config
3
+ from .placeholderalgorithmtemplate import PlaceholderAlgorithm, PlaceholderParams
4
+ from .placeholderkpitemplate import PlaceholderKPI
5
+
6
+ __all__ = [
7
+ "PlaceholderETLFactory",
8
+ "PlaceholderSchema",
9
+ "placeholder_input_config",
10
+ "PlaceholderKPI",
11
+ "PlaceholderAlgorithm",
12
+ "PlaceholderParams",
13
+ ]
@@ -0,0 +1,26 @@
1
+ from time import sleep
2
+
3
+ from algomancy_data import DataSource
4
+ from algomancy_scenario import BaseParameterSet, ScenarioResult, BaseAlgorithm
5
+
6
+
7
+ class PlaceholderParams(BaseParameterSet):
8
+ def __init__(self, name: str = "As is") -> None:
9
+ super().__init__(name=name)
10
+
11
+ def validate(self):
12
+ pass
13
+
14
+
15
+ class PlaceholderAlgorithm(BaseAlgorithm):
16
+ def __init__(self, params: PlaceholderParams):
17
+ super().__init__("As is", params)
18
+
19
+ @staticmethod
20
+ def initialize_parameters() -> PlaceholderParams:
21
+ return PlaceholderParams()
22
+
23
+ def run(self, data: DataSource) -> ScenarioResult:
24
+ sleep(0.5)
25
+ self.set_progress(100)
26
+ return ScenarioResult(data_id=data.id)
@@ -0,0 +1,26 @@
1
+ from typing import Dict
2
+
3
+ import algomancy_data as de
4
+ from algomancy_data import File
5
+ from algomancy_data.extractor import ExtractionSequence
6
+ from algomancy_data.transformer import TransformationSequence
7
+
8
+
9
+ class PlaceholderETLFactory(de.ETLFactory):
10
+ def __init__(self, configs, logger=None):
11
+ super().__init__(configs, logger)
12
+
13
+ def create_extraction_sequence(self, files: Dict[str, File]) -> ExtractionSequence:
14
+ # return the empty sequence
15
+ return ExtractionSequence(logger=self.logger)
16
+
17
+ def create_transformation_sequence(self) -> TransformationSequence:
18
+ # return the empty sequence
19
+ return TransformationSequence(logger=self.logger)
20
+
21
+ def create_validation_sequence(self) -> de.ValidationSequence:
22
+ # return the empty sequence
23
+ return de.ValidationSequence(logger=self.logger)
24
+
25
+ def create_loader(self) -> de.Loader:
26
+ return de.DataSourceLoader(self.logger)
@@ -0,0 +1,32 @@
1
+ from typing import Dict
2
+
3
+ from algomancy_data import (
4
+ Schema,
5
+ DataType,
6
+ SingleInputFileConfiguration,
7
+ FileExtension,
8
+ )
9
+
10
+
11
+ class PlaceholderSchema(Schema):
12
+ """Schema class that holds column names for placeholder data"""
13
+
14
+ @property
15
+ def datatypes(self) -> Dict[str, DataType]:
16
+ return {
17
+ "id": DataType.INTEGER,
18
+ "name": DataType.STRING,
19
+ "age": DataType.INTEGER,
20
+ "city": DataType.STRING,
21
+ "department": DataType.STRING,
22
+ "salary": DataType.INTEGER,
23
+ "hire_date": DataType.DATETIME,
24
+ "performance_score": DataType.FLOAT,
25
+ }
26
+
27
+
28
+ placeholder_input_config = SingleInputFileConfiguration(
29
+ extension=FileExtension.CSV,
30
+ file_name="placeholder_data",
31
+ file_schema=PlaceholderSchema(),
32
+ )
@@ -0,0 +1,20 @@
1
+ import random
2
+
3
+ from algomancy_scenario import (
4
+ ImprovementDirection,
5
+ BaseKPI,
6
+ ScenarioResult,
7
+ )
8
+ from algomancy_utils import QUANTITIES, BaseMeasurement
9
+
10
+
11
+ percent = QUANTITIES["percentage"]
12
+ percent_percent = BaseMeasurement(percent["%"], min_digits=1, max_digits=3, decimals=1)
13
+
14
+
15
+ class PlaceholderKPI(BaseKPI):
16
+ def __init__(self):
17
+ super().__init__("Placeholder", ImprovementDirection.HIGHER, percent_percent)
18
+
19
+ def compute(self, result: ScenarioResult) -> float:
20
+ return 50 * (1 + 0.5 * random.random())
@@ -0,0 +1,73 @@
1
+ from typing import Tuple, Dict
2
+
3
+ from algomancy_content.pages.page import (
4
+ HomePage,
5
+ DataPage,
6
+ ScenarioPage,
7
+ ComparePage,
8
+ OverviewPage,
9
+ )
10
+
11
+ from algomancy_content.pages.standarddatapage import StandardDataPage
12
+ from algomancy_content.pages.showcasehomepage import ShowcaseHomePage
13
+ from algomancy_content.pages.standardhomepage import StandardHomePage
14
+ from algomancy_content.pages.placeholderdatapage import PlaceholderDataPage
15
+ from algomancy_content.pages.placeholdercomparepage import PlaceholderComparePage
16
+ from algomancy_content.pages.placeholderscenariopage import PlaceholderScenarioPage
17
+ from algomancy_content.pages.standardoverviewpage import StandardOverviewPage
18
+
19
+
20
+ class LibraryManager:
21
+ def __init__(self):
22
+ pass
23
+
24
+ @staticmethod
25
+ def get_pages(
26
+ cfg: Dict,
27
+ ) -> Tuple[HomePage, DataPage, ScenarioPage, ComparePage, OverviewPage]:
28
+ home_choices = {
29
+ "standard": StandardHomePage,
30
+ "showcase": ShowcaseHomePage,
31
+ }
32
+ home_page = LibraryManager._get_page(cfg["home_page"], "home", home_choices)
33
+
34
+ data_choices = {
35
+ "standard": StandardDataPage,
36
+ "placeholder": PlaceholderDataPage,
37
+ }
38
+ data_page = LibraryManager._get_page(cfg["data_page"], "data", data_choices)
39
+
40
+ scenario_choices = {
41
+ "placeholder": PlaceholderScenarioPage,
42
+ }
43
+ scenario_page = LibraryManager._get_page(
44
+ cfg["scenario_page"], "scenario", scenario_choices
45
+ )
46
+
47
+ compare_choices = {
48
+ "placeholder": PlaceholderComparePage,
49
+ }
50
+ compare_page = LibraryManager._get_page(
51
+ cfg["compare_page"], "compare", compare_choices
52
+ )
53
+
54
+ overview_choices = {
55
+ "standard": StandardOverviewPage,
56
+ }
57
+ overview_page = LibraryManager._get_page(
58
+ cfg["overview_page"], "overview", overview_choices
59
+ )
60
+
61
+ return home_page, data_page, scenario_page, compare_page, overview_page
62
+
63
+ @staticmethod
64
+ def _get_page(page, identifier: str, choices: Dict):
65
+ if isinstance(page, str):
66
+ found_page = choices.get(page, None)
67
+ if not found_page:
68
+ raise ValueError(
69
+ f"Prepared component choices for {identifier} page are: {list(choices.keys())}"
70
+ )
71
+ return found_page
72
+ else:
73
+ return page
@@ -0,0 +1,31 @@
1
+ from .page import (
2
+ HomePage,
3
+ DataPage,
4
+ ScenarioPage,
5
+ ComparePage,
6
+ OverviewPage,
7
+ )
8
+
9
+ from .standarddatapage import StandardDataPage
10
+ from .showcasehomepage import ShowcaseHomePage
11
+ from .standardhomepage import StandardHomePage
12
+ from .placeholderdatapage import PlaceholderDataPage
13
+ from .placeholdercomparepage import PlaceholderComparePage
14
+ from .placeholderscenariopage import PlaceholderScenarioPage
15
+ from .standardoverviewpage import StandardOverviewPage
16
+
17
+ __all__ = [
18
+ "HomePage",
19
+ "DataPage",
20
+ "ScenarioPage",
21
+ "ComparePage",
22
+ "OverviewPage",
23
+ "PlaceholderDataPage",
24
+ "ShowcaseHomePage",
25
+ "StandardHomePage",
26
+ "StandardDataPage",
27
+ "PlaceholderDataPage",
28
+ "PlaceholderComparePage",
29
+ "PlaceholderScenarioPage",
30
+ "StandardOverviewPage",
31
+ ]
@@ -0,0 +1,49 @@
1
+ from typing import Protocol, List
2
+ from dash import html
3
+
4
+ from algomancy_data import BASE_DATA_BOUND
5
+ from algomancy_scenario import Scenario
6
+
7
+
8
+ class BasePage(Protocol):
9
+ @staticmethod
10
+ def register_callbacks() -> None:
11
+ raise NotImplementedError("Abstract method")
12
+
13
+
14
+ class HomePage(BasePage, Protocol):
15
+ @staticmethod
16
+ def create_content() -> html.Div:
17
+ raise NotImplementedError("Abstract method")
18
+
19
+
20
+ class DataPage(BasePage, Protocol):
21
+ @staticmethod
22
+ def create_content(data: BASE_DATA_BOUND) -> html.Div:
23
+ raise NotImplementedError("Abstract method")
24
+
25
+
26
+ class ScenarioPage(BasePage, Protocol):
27
+ @staticmethod
28
+ def create_content(scenario: Scenario) -> html.Div:
29
+ raise NotImplementedError("Abstract method")
30
+
31
+
32
+ class ComparePage(BasePage, Protocol):
33
+ @staticmethod
34
+ def create_side_by_side_content(scenario: Scenario, side: str) -> html.Div:
35
+ raise NotImplementedError("Abstract method")
36
+
37
+ @staticmethod
38
+ def create_compare_section(left: Scenario, right: Scenario) -> html.Div:
39
+ raise NotImplementedError("Abstract method")
40
+
41
+ @staticmethod
42
+ def create_details_section(left: Scenario, right: Scenario) -> html.Div:
43
+ raise NotImplementedError("Abstract method")
44
+
45
+
46
+ class OverviewPage(BasePage, Protocol):
47
+ @staticmethod
48
+ def create_content(scenarios: List[Scenario]) -> html.Div:
49
+ raise NotImplementedError("Abstract method")
@@ -0,0 +1,49 @@
1
+ """
2
+ Placeholder content for the Compare page - Secondary Results Component
3
+
4
+ This module defines the secondary results section component for the compare dashboard page.
5
+ It creates a collapsible section that displays additional results for the selected scenarios.
6
+ """
7
+
8
+ from dash import html
9
+
10
+ from algomancy_scenario import Scenario
11
+
12
+
13
+ class PlaceholderComparePage:
14
+ @staticmethod
15
+ def create_side_by_side_content(s: Scenario, side: str) -> html.Div:
16
+ return html.Div(
17
+ [
18
+ html.H5(f"{side.capitalize()} Scenario {s.tag}"),
19
+ html.P(f"Status: {s.status.capitalize()}"),
20
+ html.P(f"Algorithm: {s.algorithm_description}"),
21
+ ]
22
+ )
23
+
24
+ @staticmethod
25
+ def register_callbacks():
26
+ pass
27
+
28
+ @staticmethod
29
+ def create_details_section(s1: Scenario, s2: Scenario) -> html.Div:
30
+ page = html.Div(
31
+ [
32
+ html.H5("Selected Scenarios"),
33
+ html.P(f"Scenario 1: {s1.tag}"),
34
+ html.P(f"Scenario 2: {s2.tag}"),
35
+ ]
36
+ )
37
+
38
+ return page
39
+
40
+ @staticmethod
41
+ def create_compare_section(s1: Scenario, s2: Scenario) -> html.Div:
42
+ page = html.Div(
43
+ [
44
+ html.H5("This section compares selected scenarios"),
45
+ html.P(f"Scenario 1: {s1.tag}"),
46
+ html.P(f"Scenario 2: {s2.tag}"),
47
+ ]
48
+ )
49
+ return page
@@ -0,0 +1,19 @@
1
+ from dash import html
2
+
3
+ from algomancy_data import DataSource
4
+
5
+
6
+ class PlaceholderDataPage:
7
+ @staticmethod
8
+ def register_callbacks():
9
+ pass
10
+
11
+ @staticmethod
12
+ def create_content(data: DataSource):
13
+ return [
14
+ html.H5("Selected Dataset"),
15
+ html.P(f"ID: {data.id}"),
16
+ html.P(f"Name: {data.name}"),
17
+ html.Hr(),
18
+ html.Strong("Placeholder data view"),
19
+ ]
@@ -0,0 +1,24 @@
1
+ from dash import html
2
+
3
+ from algomancy_scenario import Scenario
4
+
5
+
6
+ class PlaceholderScenarioPage:
7
+ @staticmethod
8
+ def register_callbacks():
9
+ pass
10
+
11
+ @staticmethod
12
+ def create_content(s: Scenario) -> html.Div:
13
+ page = html.Div(
14
+ [
15
+ html.H5("Selected Scenario"),
16
+ html.P(f"ID: {s.id}"),
17
+ html.P(f"Tag: {s.tag}"),
18
+ html.P(f"Status: {s.status}"),
19
+ html.P(f"Algorithm: {s.algorithm_description}"),
20
+ html.P(f"Dataset: {s.input_data_key}"),
21
+ ]
22
+ )
23
+
24
+ return page