algomancy-quickstart 0.7.0__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.
Files changed (42) hide show
  1. algomancy_quickstart/__init__.py +2 -0
  2. algomancy_quickstart/asset_manager.py +202 -0
  3. algomancy_quickstart/data_inference.py +517 -0
  4. algomancy_quickstart/main.py +62 -0
  5. algomancy_quickstart/quickstart.py +683 -0
  6. algomancy_quickstart/styling_wizard.py +347 -0
  7. algomancy_quickstart/templates/__init__.py +0 -0
  8. algomancy_quickstart/templates/algorithm.py.jinja +104 -0
  9. algomancy_quickstart/templates/assets/CQM-logo-white.png +0 -0
  10. algomancy_quickstart/templates/assets/cqm-button-white.png +0 -0
  11. algomancy_quickstart/templates/assets/cqm-button.png +0 -0
  12. algomancy_quickstart/templates/assets/cqm-logo.png +0 -0
  13. algomancy_quickstart/templates/assets/css/button_colors.css +285 -0
  14. algomancy_quickstart/templates/assets/css/cqm_loader.css +47 -0
  15. algomancy_quickstart/templates/assets/css/sidebar_layout.css +189 -0
  16. algomancy_quickstart/templates/assets/css/theme_colors.css +90 -0
  17. algomancy_quickstart/templates/assets/letter-c.svg +4 -0
  18. algomancy_quickstart/templates/assets/letter-m.svg +4 -0
  19. algomancy_quickstart/templates/assets/letter-q.svg +4 -0
  20. algomancy_quickstart/templates/assets/letters/letter-c.png +0 -0
  21. algomancy_quickstart/templates/assets/letters/letter-m.png +0 -0
  22. algomancy_quickstart/templates/assets/letters/letter-q.png +0 -0
  23. algomancy_quickstart/templates/assets/pepsi_girl.jpeg +0 -0
  24. algomancy_quickstart/templates/assets/style.css +421 -0
  25. algomancy_quickstart/templates/compare_page.py.jinja +133 -0
  26. algomancy_quickstart/templates/data_page.py.jinja +94 -0
  27. algomancy_quickstart/templates/etl_factory.py.jinja +108 -0
  28. algomancy_quickstart/templates/etl_factory_generated.py.jinja +82 -0
  29. algomancy_quickstart/templates/generated_schemas.py.jinja +55 -0
  30. algomancy_quickstart/templates/home_page.py.jinja +65 -0
  31. algomancy_quickstart/templates/kpi.py.jinja +76 -0
  32. algomancy_quickstart/templates/main.py.jinja +42 -0
  33. algomancy_quickstart/templates/main_custom.py.jinja +55 -0
  34. algomancy_quickstart/templates/main_generated_etl.py.jinja +72 -0
  35. algomancy_quickstart/templates/main_with_styling.py.jinja +83 -0
  36. algomancy_quickstart/templates/overview_page.py.jinja +98 -0
  37. algomancy_quickstart/templates/scenario_page.py.jinja +77 -0
  38. algomancy_quickstart/templates/schema.py.jinja +58 -0
  39. algomancy_quickstart/templates/styling_config.py.jinja +53 -0
  40. algomancy_quickstart-0.7.0.dist-info/METADATA +29 -0
  41. algomancy_quickstart-0.7.0.dist-info/RECORD +42 -0
  42. algomancy_quickstart-0.7.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,2 @@
1
+ def hello() -> str:
2
+ return "Hello from algomancy-quickstart!"
@@ -0,0 +1,202 @@
1
+ """
2
+ Asset management utilities for downloading and copying default assets.
3
+ """
4
+
5
+ import shutil
6
+ import tempfile
7
+ import zipfile
8
+ from pathlib import Path
9
+ import click
10
+ import requests
11
+
12
+
13
+ class AssetManager:
14
+ """Manages downloading and installing default Algomancy assets."""
15
+
16
+ # GitHub repository details
17
+ GITHUB_REPO = "PepijnWissing/algomancy"
18
+ GITHUB_BRANCH = "main"
19
+ ASSETS_PATH = "example/assets"
20
+
21
+ def __init__(self, target_dir: Path):
22
+ """
23
+ Initialize the asset manager.
24
+
25
+ Args:
26
+ target_dir: Target directory where assets should be installed.
27
+ """
28
+ self.target_dir = target_dir
29
+ self.assets_dir = target_dir / "assets"
30
+
31
+ def install_assets(self, skip_confirmation: bool = False) -> bool:
32
+ """
33
+ Install default assets, either from GitHub or bundled fallback.
34
+
35
+ Args:
36
+ skip_confirmation: If True, skip confirmation prompts.
37
+
38
+ Returns:
39
+ True if assets were installed successfully.
40
+ """
41
+ click.echo(
42
+ click.style("📦 Step 4: Installing default assets", fg="blue", bold=True)
43
+ )
44
+ click.echo()
45
+
46
+ # Check if assets directory already has files
47
+ if self.assets_dir.exists() and list(self.assets_dir.iterdir()):
48
+ click.echo(click.style("⚠️ Assets directory is not empty", fg="yellow"))
49
+
50
+ existing_files = list(self.assets_dir.iterdir())
51
+ click.echo(f"Found {len(existing_files)} existing item(s)")
52
+
53
+ if not skip_confirmation:
54
+ choice = click.prompt(
55
+ "What would you like to do?",
56
+ type=click.Choice(
57
+ ["merge", "skip", "overwrite"], case_sensitive=False
58
+ ),
59
+ default="merge",
60
+ )
61
+
62
+ if choice == "skip":
63
+ click.echo("Skipping asset installation.")
64
+ return False
65
+ elif choice == "overwrite":
66
+ click.echo("Removing existing assets...")
67
+ shutil.rmtree(self.assets_dir)
68
+ self.assets_dir.mkdir(parents=True)
69
+ # 'merge' continues without deletion
70
+
71
+ # Ensure assets directory exists
72
+ self.assets_dir.mkdir(parents=True, exist_ok=True)
73
+
74
+ # Try downloading from GitHub first
75
+ click.echo("Attempting to download assets from GitHub...")
76
+ if self._download_from_github():
77
+ click.echo(click.style(" ✓ Assets downloaded successfully!", fg="green"))
78
+ return True
79
+
80
+ # Fallback to bundled assets
81
+ click.echo()
82
+ click.echo(
83
+ click.style(
84
+ "⚠️ Could not download from GitHub, using bundled assets", fg="yellow"
85
+ )
86
+ )
87
+
88
+ if self._install_bundled_assets():
89
+ click.echo(
90
+ click.style(" ✓ Bundled assets installed successfully!", fg="green")
91
+ )
92
+ return True
93
+
94
+ click.echo(click.style(" ❌ Failed to install assets", fg="red"))
95
+ return False
96
+
97
+ def _download_from_github(self) -> bool:
98
+ """
99
+ Download assets from GitHub repository.
100
+
101
+ Returns:
102
+ True if download was successful.
103
+ """
104
+ try:
105
+ # Construct URL for downloading the repository archive
106
+ url = f"https://github.com/{self.GITHUB_REPO}/archive/refs/heads/{self.GITHUB_BRANCH}.zip"
107
+
108
+ click.echo(f" Downloading from: {url}")
109
+
110
+ # Download with timeout
111
+ response = requests.get(url, timeout=30, stream=True)
112
+ response.raise_for_status()
113
+
114
+ # Create temporary directory for extraction
115
+ with tempfile.TemporaryDirectory() as temp_dir:
116
+ temp_path = Path(temp_dir)
117
+ zip_path = temp_path / "repo.zip"
118
+
119
+ # Save zip file
120
+ with open(zip_path, "wb") as f:
121
+ for chunk in response.iter_content(chunk_size=8192):
122
+ f.write(chunk)
123
+
124
+ click.echo(" Extracting assets...")
125
+
126
+ # Extract zip file
127
+ with zipfile.ZipFile(zip_path, "r") as zip_ref:
128
+ zip_ref.extractall(temp_path)
129
+
130
+ # Find the extracted repository folder
131
+ extracted_dirs = [d for d in temp_path.iterdir() if d.is_dir()]
132
+ if not extracted_dirs:
133
+ return False
134
+
135
+ repo_dir = extracted_dirs[0]
136
+ source_assets = repo_dir / self.ASSETS_PATH
137
+
138
+ if not source_assets.exists():
139
+ click.echo(
140
+ f" ⚠️ Assets not found in repository at {self.ASSETS_PATH}"
141
+ )
142
+ return False
143
+
144
+ # Copy assets to target directory
145
+ self._copy_assets(source_assets, self.assets_dir)
146
+
147
+ return True
148
+
149
+ except requests.exceptions.RequestException as e:
150
+ click.echo(f" ⚠️ Network error: {e}")
151
+ return False
152
+ except Exception as e:
153
+ click.echo(f" ⚠️ Error downloading assets: {e}")
154
+ return False
155
+
156
+ def _install_bundled_assets(self) -> bool:
157
+ """
158
+ Install bundled fallback assets from the package.
159
+
160
+ Returns:
161
+ True if installation was successful.
162
+ """
163
+ try:
164
+ # Get path to bundled assets within the package
165
+ from importlib.resources import files
166
+
167
+ package_assets = files("algomancy_quickstart").joinpath("templates/assets")
168
+
169
+ if not package_assets.is_dir():
170
+ click.echo(" ⚠️ Bundled assets not found in package")
171
+ return False
172
+
173
+ # Copy bundled assets
174
+ self._copy_assets(Path(str(package_assets)), self.assets_dir)
175
+
176
+ return True
177
+
178
+ except Exception as e:
179
+ click.echo(f" ⚠️ Error installing bundled assets: {e}")
180
+ return False
181
+
182
+ def _copy_assets(self, source: Path, target: Path) -> None:
183
+ """
184
+ Copy assets from source to target directory.
185
+
186
+ Args:
187
+ source: Source directory containing assets.
188
+ target: Target directory where assets should be copied.
189
+ """
190
+ for item in source.iterdir():
191
+ target_item = target / item.name
192
+
193
+ if item.is_file():
194
+ shutil.copy2(item, target_item)
195
+ click.echo(f" • {item.name}")
196
+ elif item.is_dir():
197
+ if target_item.exists():
198
+ # Merge directories
199
+ self._copy_assets(item, target_item)
200
+ else:
201
+ shutil.copytree(item, target_item)
202
+ click.echo(f" • {item.name}/")