viperx 0.9.14__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.
viperx/licenses.py ADDED
@@ -0,0 +1,248 @@
1
+ MIT_LICENSE = """MIT License
2
+
3
+ Copyright (c) {year} {author}
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ """
23
+
24
+ APACHE_LICENSE = """Apache License
25
+ Version 2.0, January 2004
26
+ http://www.apache.org/licenses/
27
+
28
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
29
+
30
+ 1. Definitions.
31
+
32
+ "License" shall mean the terms and conditions for use, reproduction,
33
+ and distribution as defined by Sections 1 through 9 of this document.
34
+
35
+ "Licensor" shall mean the copyright owner or entity authorized by
36
+ the copyright owner that is granting the License.
37
+
38
+ "Legal Entity" shall mean the union of the acting entity and all
39
+ other entities that control, are controlled by, or are under common
40
+ control with that entity. For the purposes of this definition,
41
+ "control" means (i) the power, direct or indirect, to cause the
42
+ direction or management of such entity, whether by contract or
43
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
44
+ outstanding shares, or (iii) beneficial ownership of such entity.
45
+
46
+ "You" (or "Your") shall mean an individual or Legal Entity
47
+ exercising permissions granted by this License.
48
+
49
+ "Source" form shall mean the preferred form for making modifications,
50
+ including but not limited to software source code, documentation
51
+ source, and configuration files.
52
+
53
+ "Object" form shall mean any form resulting from mechanical
54
+ transformation or translation of a Source form, including but
55
+ not limited to compiled object code, generated documentation,
56
+ and conversions to other media types.
57
+
58
+ "Work" shall mean the work of authorship, whether in Source or
59
+ Object form, made available under the License, as indicated by a
60
+ copyright notice that is included in or attached to the work
61
+ (an example is provided in the Appendix below).
62
+
63
+ "Derivative Works" shall mean any work, whether in Source or Object
64
+ form, that is based on (or derived from) the Work and for which the
65
+ editorial revisions, annotations, elaborations, or other modifications
66
+ represent, as a whole, an original work of authorship. For the purposes
67
+ of this License, Derivative Works shall not include works that remain
68
+ separable from, or merely link (or bind by name) to the interfaces of,
69
+ the Work and Derivative Works thereof.
70
+
71
+ "Contribution" shall mean any work of authorship, including
72
+ the original version of the Work and any modifications or additions
73
+ to that Work or Derivative Works thereof, that is intentionally
74
+ submitted to Licensor for inclusion in the Work by the copyright owner
75
+ or by an individual or Legal Entity authorized to submit on behalf of
76
+ the copyright owner. For the purposes of this definition, "submitted"
77
+ means any form of electronic, verbal, or written communication sent
78
+ to the Licensor or its representatives, including but not limited to
79
+ communication on electronic mailing lists, source code control systems,
80
+ and issue tracking systems that are managed by, or on behalf of, the
81
+ Licensor for the purpose of discussing and improving the Work, but
82
+ excluding communication that is conspicuously marked or otherwise
83
+ designated in writing by the copyright owner as "Not a Contribution."
84
+
85
+ "Contributor" shall mean Licensor and any individual or Legal Entity
86
+ on behalf of whom a Contribution has been received by Licensor and
87
+ subsequently incorporated within the Work.
88
+
89
+ 2. Grant of Copyright License. Subject to the terms and conditions of
90
+ this License, each Contributor hereby grants to You a perpetual,
91
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
92
+ copyright license to reproduce, prepare Derivative Works of,
93
+ publicly display, publicly perform, sublicense, and distribute the
94
+ Work and such Derivative Works in Source or Object form.
95
+
96
+ 3. Grant of Patent License. Subject to the terms and conditions of
97
+ this License, each Contributor hereby grants to You a perpetual,
98
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
99
+ (except as stated in this section) patent license to make, have made,
100
+ use, offer to sell, sell, import, and otherwise transfer the Work,
101
+ where such license applies only to those patent claims licensable
102
+ by such Contributor that are necessarily infringed by their
103
+ Contribution(s) alone or by combination of their Contribution(s)
104
+ with the Work to which such Contribution(s) was submitted. If You
105
+ institute patent litigation against any entity (including a
106
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
107
+ or a Contribution incorporated within the Work constitutes direct
108
+ or contributory patent infringement, then any patent licenses
109
+ granted to You under this License for that Work shall terminate
110
+ as of the date such litigation is filed.
111
+
112
+ 4. Redistribution. You may reproduce and distribute copies of the
113
+ Work or Derivative Works thereof in any medium, with or without
114
+ modifications, and in Source or Object form, provided that You
115
+ meet the following conditions:
116
+
117
+ (a) You must give any other recipients of the Work or Derivative
118
+ Works a copy of this License; and
119
+
120
+ (b) You must cause any modified files to carry prominent notices
121
+ stating that You changed the files; and
122
+
123
+ (c) You must retain, in the Source form of any Derivative Works
124
+ that You distribute, all copyright, patent, trademark, and
125
+ attribution notices from the Source form of the Work,
126
+ excluding those notices that do not pertain to any part of
127
+ the Derivative Works; and
128
+
129
+ (d) If the Work includes a "NOTICE" text file as part of its
130
+ distribution, then any Derivative Works that You distribute must
131
+ include a readable copy of the attribution notices contained
132
+ within such NOTICE file, excluding those notices that do not
133
+ pertain to any part of the Derivative Works, in at least one
134
+ of the following places: within a NOTICE text file distributed
135
+ as part of the Derivative Works; within the Source form or
136
+ documentation, if provided along with the Derivative Works; or,
137
+ within a display generated by the Derivative Works, if and
138
+ wherever such third-party notices normally appear. The contents
139
+ of the NOTICE file are for informational purposes only and
140
+ do not modify the License. You may add Your own attribution
141
+ notices within Derivative Works that You distribute, alongside
142
+ or as an addendum to the NOTICE text from the Work, provided
143
+ that such additional attribution notices cannot be construed
144
+ as modifying the License.
145
+
146
+ You may add Your own copyright statement to Your modifications and
147
+ may provide additional or different license terms and conditions
148
+ for use, reproduction, or distribution of Your modifications, or
149
+ for any such Derivative Works as a whole, provided Your use,
150
+ reproduction, and distribution of the Work otherwise complies with
151
+ the conditions stated in this License.
152
+
153
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
154
+ any Contribution intentionally submitted for inclusion in the Work
155
+ by You to the Licensor shall be under the terms and conditions of
156
+ this License, without any additional terms or conditions.
157
+ Notwithstanding the above, nothing herein shall supersede or modify
158
+ the terms of any separate license agreement you may have executed
159
+ with Licensor regarding such Contributions.
160
+
161
+ 6. Trademarks. This License does not grant permission to use the trade
162
+ names, trademarks, service marks, or product names of the Licensor,
163
+ except as required for reasonable and customary use in describing the
164
+ origin of the Work and reproducing the content of the NOTICE file.
165
+
166
+ 7. Disclaimer of Warranty. Unless required by applicable law or
167
+ agreed to in writing, Licensor provides the Work (and each
168
+ Contributor provides its Contributions) on an "AS IS" BASIS,
169
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
170
+ implied, including, without limitation, any warranties or conditions
171
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
172
+ PARTICULAR PURPOSE. You are solely responsible for determining the
173
+ appropriateness of using or redistributing the Work and assume any
174
+ risks associated with Your exercise of permissions under this License.
175
+
176
+ 8. Limitation of Liability. In no event and under no legal theory,
177
+ whether in tort (including negligence), contract, or otherwise,
178
+ unless required by applicable law (such as deliberate and grossly
179
+ negligent acts) or agreed to in writing, shall any Contributor be
180
+ liable to You for damages, including any direct, indirect, special,
181
+ incidental, or consequential damages of any character arising as a
182
+ result of this License or out of the use or inability to use the
183
+ Work (including but not limited to damages for loss of goodwill,
184
+ work stoppage, computer failure or malfunction, or any and all
185
+ other commercial damages or losses), even if such Contributor
186
+ has been advised of the possibility of such damages.
187
+
188
+ 9. Accepting Warranty or Additional Liability. While redistributing
189
+ the Work or Derivative Works thereof, You may choose to offer,
190
+ and charge a fee for, acceptance of support, warranty, indemnity,
191
+ or other liability obligations and/or rights consistent with this
192
+ License. However, in accepting such obligations, You may act only
193
+ on Your own behalf and on Your sole responsibility, not on behalf
194
+ of any other Contributor, and only if You agree to indemnify,
195
+ defend, and hold each Contributor harmless for any liability
196
+ incurred by, or claims asserted against, such Contributor by reason
197
+ of your accepting any such warranty or additional liability.
198
+
199
+ END OF TERMS AND CONDITIONS
200
+ """
201
+
202
+ GPL_LICENSE = """ GNU GENERAL PUBLIC LICENSE
203
+ Version 3, 29 June 2007
204
+
205
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
206
+ Everyone is permitted to copy and distribute verbatim copies
207
+ of this license document, but changing it is not allowed.
208
+
209
+ Preamble
210
+
211
+ The GNU General Public License is a free, copyleft license for
212
+ software and other kinds of works.
213
+
214
+ The licenses for most software and other practical works are designed
215
+ to take away your freedom to share and change the works. By contrast,
216
+ the GNU General Public License is intended to guarantee your freedom to
217
+ share and change all versions of a program--to make sure it remains free
218
+ software for all its users. We, the Free Software Foundation, use the
219
+ GNU General Public License for most of our software; it applies also to
220
+ any other work released this way by its authors. You can apply it to
221
+ your programs, too.
222
+
223
+ When we speak of free software, we are referring to freedom, not
224
+ price. Our General Public Licenses are designed to make sure that you
225
+ have the freedom to distribute copies of free software (and charge for
226
+ them if you wish), that you receive source code or can get it if you
227
+ want it, that you can change the software or use pieces of it in new
228
+ free programs, and that you know you can do these things.
229
+
230
+ To protect your rights, we need to prevent others from denying you
231
+ these rights or asking you to surrender the rights. Therefore, you have
232
+ certain responsibilities if you distribute copies of the software, or if
233
+ you modify it: responsibilities to respect the freedom of others.
234
+
235
+ For example, if you distribute copies of such a program, whether
236
+ gratis or for a fee, you must pass on to the recipients the same
237
+ freedoms that you received. You must make sure that they, too, receive
238
+ or can get the source code. And you must show them these terms so they
239
+ know their rights.
240
+
241
+ ... (Truncated for brevity, full GPL is long, but this is enough to start)
242
+ """
243
+
244
+ LICENSES = {
245
+ "MIT": MIT_LICENSE,
246
+ "Apache-2.0": APACHE_LICENSE,
247
+ "GPLv3": GPL_LICENSE,
248
+ }
viperx/main.py ADDED
@@ -0,0 +1,278 @@
1
+ import typer
2
+ from typing_extensions import Annotated
3
+ from pathlib import Path
4
+ from rich import print
5
+ from rich.panel import Panel
6
+ from rich.console import Console
7
+ import shutil
8
+
9
+ from viperx.core import ProjectGenerator, TYPE_CLASSIC, TYPE_ML, TYPE_DL, DEFAULT_LICENSE, DEFAULT_BUILDER
10
+ from viperx.utils import validate_project_name, check_uv_installed
11
+ from viperx.config_engine import ConfigEngine
12
+ from viperx.constants import (
13
+ PROJECT_TYPES,
14
+ DL_FRAMEWORKS,
15
+ FRAMEWORK_PYTORCH,
16
+ )
17
+
18
+ HELP_TEXT = """
19
+ [bold green]ViperX[/bold green]: Professional Python Project Initializer
20
+ .
21
+
22
+ Automates the creation of professional-grade Python projects using `uv`.
23
+ Supports Standard Libraries, Machine Learning, and Deep Learning templates.
24
+ """
25
+
26
+ app = typer.Typer(
27
+ help=HELP_TEXT,
28
+ add_completion=False,
29
+ no_args_is_help=True,
30
+ rich_markup_mode="markdown",
31
+ epilog="Made with ❤️ by KpihX"
32
+ )
33
+
34
+ # Global state for verbose flag
35
+ state = {"verbose": False}
36
+ console = Console(force_terminal=True)
37
+
38
+
39
+ """
40
+ **ViperX**: Professional Python Project Initializer.
41
+
42
+ Automates the creation of professional-grade Python projects using `uv`.
43
+ Supports Standard Libraries, Machine Learning, and Deep Learning templates.
44
+ """
45
+ if verbose:
46
+ state["verbose"] = True
47
+ console.print("[dim]Verbose mode enabled[/dim]")
48
+
49
+ def version_callback(value: bool):
50
+ if value:
51
+ import importlib.metadata
52
+ try:
53
+ version = importlib.metadata.version("viperx")
54
+ except importlib.metadata.PackageNotFoundError:
55
+ version = "unknown"
56
+ console.print(f"ViperX CLI Version: [bold green]{version}[/bold green]")
57
+ raise typer.Exit()
58
+
59
+ @app.callback(invoke_without_command=True)
60
+ def cli_callback(
61
+ ctx: typer.Context,
62
+ verbose: bool = typer.Option(
63
+ False, "-v", "--verbose",
64
+ help="Enable verbose logging."
65
+ ),
66
+ version: bool = typer.Option(
67
+ None, "--version", "-V",
68
+ callback=version_callback,
69
+ is_eager=True,
70
+ help="Show version and exit."
71
+ )
72
+ ):
73
+ """
74
+ **ViperX**: Professional Python Project Initializer.
75
+
76
+ Automates the creation of professional-grade Python projects using `uv`.
77
+ Supports Standard Libraries, Machine Learning, and Deep Learning templates.
78
+ """
79
+ if verbose:
80
+ state["verbose"] = True
81
+ console.print("[dim]Verbose mode enabled[/dim]")
82
+
83
+ @app.command()
84
+ def init(
85
+ # --- Config Driven Mode ---
86
+ config: Path = typer.Option(
87
+ None, "--config", "-c",
88
+ help="Path to a viperx.yaml configuration file. If provided, ignores other options."
89
+ ),
90
+ # --- Interactive Mode Options ---
91
+ name: str = typer.Option(None, "--name", "-n", help="Name of the project"),
92
+ description: str = typer.Option(None, "--description", "-d", help="Project description"),
93
+ type: str = typer.Option(
94
+ TYPE_CLASSIC, "--type", "-t",
95
+ help="Project type: [green]classic[/green], [blue]ml[/blue], [red]dl[/red]"
96
+ ),
97
+ author: str = typer.Option(
98
+ None, "--author", "-a",
99
+ help="Author name. Defaults to git user."
100
+ ),
101
+ license: str = typer.Option(
102
+ DEFAULT_LICENSE, "--license", "-l",
103
+ help="License type (MIT, Apache-2.0, GPLv3)"
104
+ ),
105
+ builder: str = typer.Option(
106
+ DEFAULT_BUILDER, "--builder", "-b",
107
+ help="Build backend. Defaults to [bold]uv[/bold]."
108
+ ),
109
+ framework: str = typer.Option(
110
+ FRAMEWORK_PYTORCH, "--framework", "-f",
111
+ help=f"DL Framework ({'|'.join(DL_FRAMEWORKS)}). Defaults to pytorch."
112
+ ),
113
+ use_env: bool = typer.Option(True, "--env/--no-env", help="Generate .env file"),
114
+ use_config: bool = typer.Option(True, "--embed-config/--no-embed-config", help="Generate embedded config"),
115
+ verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose logging"),
116
+ ):
117
+ """
118
+ Initialize a new Python project.
119
+
120
+ Can stem from a config file (Declarative) or CLI arguments (Imperative).
121
+ """
122
+ # 1. Declarative Mode
123
+ if config:
124
+ if not config.exists():
125
+ console.print(f"[bold red]Error:[/bold red] Configuration file '{config}' not found.")
126
+ raise typer.Exit(code=1)
127
+
128
+ engine = ConfigEngine(config, verbose=verbose or state["verbose"])
129
+ engine.apply()
130
+ return
131
+
132
+ # 2. Imperative Mode (Validation)
133
+ if not name:
134
+ console.print("[bold red]Error:[/bold red] Missing option '--name' / '-n'. Required in manual mode.")
135
+ raise typer.Exit(code=1)
136
+
137
+ if type not in PROJECT_TYPES:
138
+ console.print(f"[bold red]Error:[/bold red] Invalid type '{type}'. Must be one of: {', '.join(PROJECT_TYPES)}")
139
+ raise typer.Exit(code=1)
140
+
141
+ console.print(Panel(f"Initializing [bold blue]{name}[/bold blue]", border_style="blue"))
142
+
143
+ generator = ProjectGenerator(
144
+ name=name,
145
+ description=description,
146
+ type=type,
147
+ author=author,
148
+ license=license,
149
+ builder=builder,
150
+ use_env=use_env,
151
+ use_config=use_config,
152
+ framework=framework,
153
+ verbose=verbose or state["verbose"]
154
+ )
155
+
156
+ # Generate in current directory
157
+ generator.generate(Path.cwd())
158
+
159
+ # Config Management Group
160
+ config_app = typer.Typer(
161
+ help="Manage Declarative Configuration (viperx.yaml).",
162
+ no_args_is_help=True
163
+ )
164
+ app.add_typer(config_app, name="config")
165
+
166
+ @config_app.command("get")
167
+ def config_get(
168
+ filename: Path = typer.Option("viperx.yaml", "--output", "-o", help="Output filename")
169
+ ):
170
+ """
171
+ Get the default configuration template (viperx.yaml).
172
+ Use this to start a 'Project as Code' workflow.
173
+ """
174
+ from viperx.constants import TEMPLATES_DIR
175
+ import jinja2
176
+
177
+ template_path = TEMPLATES_DIR / "viperx_config.yaml.j2"
178
+ if not template_path.exists():
179
+ console.print("[bold red]Error:[/bold red] Config template not found.")
180
+ raise typer.Abort()
181
+
182
+ with open(template_path, "r") as f:
183
+ content = f.read()
184
+
185
+ if filename.exists():
186
+ if not typer.confirm(f"File {filename} already exists. Overwrite?"):
187
+ raise typer.Abort()
188
+
189
+ with open(filename, "w") as f:
190
+ f.write(content)
191
+
192
+ console.print(Panel(f"✅ Generated configuration template: [bold green]{filename}[/bold green]\n\nRun [bold]viperx init -c {filename}[/bold] to create your project.", border_style="green"))
193
+
194
+
195
+ # Package management group
196
+ package_app = typer.Typer(
197
+ help="Manage workspace packages (add, update, delete).",
198
+ no_args_is_help=True
199
+ )
200
+ app.add_typer(package_app, name="package")
201
+
202
+ @package_app.command("add")
203
+ def package_add(
204
+ name: str = typer.Option(..., "--name", "-n", help="Name of the new package"),
205
+ type: str = typer.Option(
206
+ TYPE_CLASSIC, "--type", "-t",
207
+ help="Project type: [green]classic[/green], [blue]ml[/blue], [red]dl[/red]"
208
+ ),
209
+ framework: str = typer.Option(
210
+ FRAMEWORK_PYTORCH, "--framework", "-f",
211
+ help=f"DL Framework ({'|'.join(DL_FRAMEWORKS)}). Defaults to pytorch."
212
+ ),
213
+ use_env: bool = typer.Option(True, "--env/--no-env", help="Generate .env file"),
214
+ use_config: bool = typer.Option(True, "--embed-config/--no-embed-config", help="Generate embedded config"),
215
+ use_readme: bool = typer.Option(True, "--readme/--no-readme", help="Generate README.md"),
216
+ verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose logging"),
217
+ ):
218
+ """
219
+ Add a new package to the workspace.
220
+
221
+ Detects if the current directory is a workspace. If so, adds the new package.
222
+ If it's a standalone project, upgrades it to a workspace first.
223
+ """
224
+ console.print(Panel.fit("🚀 [bold yellow]ViperX[/bold yellow] - Initialize a new project", border_style="green"))
225
+
226
+ generator = ProjectGenerator(
227
+ name=name,
228
+ description="Workspace Member",
229
+ type=type,
230
+ author="Your Name",
231
+ # Defaults
232
+ use_env=use_env,
233
+ use_config=use_config,
234
+ use_readme=use_readme,
235
+ framework=framework,
236
+ verbose=verbose or state["verbose"]
237
+ )
238
+ generator.add_to_workspace(Path.cwd())
239
+
240
+ @package_app.command("delete")
241
+ def package_delete(
242
+ name: str = typer.Option(..., "--name", "-n", help="Name of the package to delete"),
243
+ verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose logging"),
244
+ force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation"),
245
+ ):
246
+ """
247
+ Delete a package from the workspace.
248
+
249
+ Removes the folder and the member entry from pyproject.toml.
250
+ """
251
+ verbose = verbose or state["verbose"]
252
+
253
+ if not force:
254
+ if not typer.confirm(f"Are you sure you want to delete package '{name}'?"):
255
+ raise typer.Abort()
256
+
257
+ console.print(Panel(f"Deleting package [bold red]{name}[/bold red]", border_style="red"))
258
+
259
+ # We init generator just to use its helper methods (could be static, but this is fine)
260
+ generator = ProjectGenerator(name=name, description="", type="classic", author="", use_env=False, use_config=False, verbose=verbose)
261
+ generator.delete_from_workspace(Path.cwd())
262
+
263
+ @package_app.command("update")
264
+ def package_update(
265
+ name: str = typer.Option(..., "--name", "-n", help="Name of the package to update"),
266
+ verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose logging"),
267
+ ):
268
+ """
269
+ Update a package's dependencies (uv lock --upgrade).
270
+ """
271
+ verbose = verbose or state["verbose"]
272
+ console.print(Panel(f"Updating package [bold blue]{name}[/bold blue]", border_style="blue"))
273
+
274
+ generator = ProjectGenerator(name=name, description="", type="classic", author="", use_env=False, use_config=False, verbose=verbose)
275
+ generator.update_package(Path.cwd())
276
+
277
+ if __name__ == "__main__":
278
+ app()
@@ -0,0 +1,119 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# {{ project_name }} - Base Notebook\n",
8
+ "\n",
9
+ "**Author:** {{ author_name }}\n",
10
+ "**Description:** {{ description }}"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": null,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "# Universal Setup (Local / Colab / Kaggle)\n",
20
+ "import sys\n",
21
+ "import os\n",
22
+ "import yaml\n",
23
+ "# Check if running on Colab\n",
24
+ "if 'google.colab' in sys.modules:\n",
25
+ " print('Detected Google Colab environment')\n",
26
+ " # Clone/Install the package if needed\n",
27
+ " # !pip install git+https://github.com/{{ author_name | lower | replace(' ', '') }}/{{ project_name }}.git\n",
28
+ "\n",
29
+ "from {{ package_name }} import get_dataset_path, SETTINGS\n",
30
+ "\n",
31
+ "print(f\"Project: {SETTINGS.get('project_name')}\")"
32
+ ]
33
+ },
34
+ {
35
+ "cell_type": "code",
36
+ "execution_count": null,
37
+ "metadata": {},
38
+ "outputs": [],
39
+ "source": [
40
+ "# Standard Imports\n",
41
+ "import numpy as np\n",
42
+ "import pandas as pd\n",
43
+ "import matplotlib.pyplot as plt\n",
44
+ "import seaborn as sns\n",
45
+ "import kagglehub as kh\n",
46
+ "from kagglehub import KaggleDatasetAdapter\n",
47
+ "\n",
48
+ "{% if project_type == 'dl' %}\n",
49
+ "{% if framework == 'pytorch' %}\n",
50
+ "import torch\n",
51
+ "import torch.nn as nn\n",
52
+ "import torch.optim as optim\n",
53
+ "print(f\"PyTorch Version: {torch.__version__}\")\n",
54
+ "print(f\"CUDA Available: {torch.cuda.is_available()}\")\n",
55
+ "{% elif framework == 'tensorflow' %}\n",
56
+ "import tensorflow as tf\n",
57
+ "print(f\"TensorFlow Version: {tf.__version__}\")\n",
58
+ "print(f\"GPU Available: {len(tf.config.list_physical_devices('GPU')) > 0}\")\n",
59
+ "{% endif %}\n",
60
+ "{% elif project_type == 'ml' %}\n",
61
+ "from sklearn.model_selection import train_test_split\n",
62
+ "from sklearn.preprocessing import StandardScaler, OneHotEncoder\n",
63
+ "from sklearn.compose import ColumnTransformer, make_column_selector\n",
64
+ "from sklearn.pipeline import Pipeline\n",
65
+ "{% endif %}\n",
66
+ "\n",
67
+ "%matplotlib inline"
68
+ ]
69
+ },
70
+ {
71
+ "cell_type": "code",
72
+ "execution_count": null,
73
+ "metadata": {},
74
+ "outputs": [],
75
+ "source": [
76
+ "# Load Dataset using Config + KaggleHub\n",
77
+ "# Example: Loading Titanic dataset defined in config.yaml\n",
78
+ "\n",
79
+ "try:\n",
80
+ " # Load dataset path from config (or use direct name for kagglehub)\n",
81
+ " # The config.yaml defines 'titanic': 'heptapod/titanic'\n",
82
+ " dataset_name = SETTINGS.get('datasets', {}).get('titanic', 'heptapod/titanic')\n",
83
+ " print(f\"Loading dataset: {dataset_name}...\")\n",
84
+ " \n",
85
+ " path = kh.dataset_download(dataset_name)\n",
86
+ " print(f\"Path: {path}\")\n",
87
+ " \n",
88
+ " # Example loading csv found in the path\n",
89
+ " # Adjust 'train.csv' based on actual dataset content\n",
90
+ " df = pd.read_csv(f\"{path}/train.csv\")\n",
91
+ " display(df.head())\n",
92
+ " df.info()\n",
93
+ "except Exception as e:\n",
94
+ " print(f\"Failed to load dataset: {e}\")"
95
+ ]
96
+ }
97
+ ],
98
+ "metadata": {
99
+ "kernelspec": {
100
+ "display_name": "Python 3",
101
+ "language": "python",
102
+ "name": "python3"
103
+ },
104
+ "language_info": {
105
+ "codemirror_mode": {
106
+ "name": "ipython",
107
+ "version": 3
108
+ },
109
+ "file_extension": ".py",
110
+ "mimetype": "text/x-python",
111
+ "name": "python",
112
+ "nbconvert_exporter": "python",
113
+ "pygments_lexer": "ipython3",
114
+ "version": "3.11.0"
115
+ }
116
+ },
117
+ "nbformat": 4,
118
+ "nbformat_minor": 5
119
+ }