dscforge 0.1.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.
- dscforge/__init__.py +0 -0
- dscforge/cli.py +30 -0
- dscforge/generator.py +129 -0
- dscforge/templates/basic/main.py +9 -0
- dscforge/templates/premium/src/__init__.py +0 -0
- dscforge/templates/premium/src/config.py +33 -0
- dscforge/templates/premium/src/main.py +14 -0
- dscforge/templates/premium/src/utils.py +11 -0
- dscforge/templates/premium/tests/test.py +15 -0
- dscforge/templates/standard/src/main.py +11 -0
- dscforge/utils.py +0 -0
- dscforge-0.1.0.dist-info/METADATA +7 -0
- dscforge-0.1.0.dist-info/RECORD +16 -0
- dscforge-0.1.0.dist-info/WHEEL +5 -0
- dscforge-0.1.0.dist-info/entry_points.txt +2 -0
- dscforge-0.1.0.dist-info/top_level.txt +1 -0
dscforge/__init__.py
ADDED
|
File without changes
|
dscforge/cli.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Imports
|
|
2
|
+
import click
|
|
3
|
+
from .generator import create_project
|
|
4
|
+
|
|
5
|
+
@click.command()
|
|
6
|
+
@click.argument("name")
|
|
7
|
+
|
|
8
|
+
# Click option for --template
|
|
9
|
+
@click.option(
|
|
10
|
+
"--template",
|
|
11
|
+
type=click.Choice(["basic", "standard", "premium"]),
|
|
12
|
+
default="basic",
|
|
13
|
+
show_default=True,
|
|
14
|
+
help="Select a project template"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
# Click option for --git
|
|
18
|
+
@click.option(
|
|
19
|
+
"--git",
|
|
20
|
+
is_flag=True,
|
|
21
|
+
default=False,
|
|
22
|
+
help="Initialize a git repository in the project"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Creating the template
|
|
26
|
+
def main(name, template, git):
|
|
27
|
+
create_project(name, template, git)
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
main()
|
dscforge/generator.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Imports
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
# Base Dependencies
|
|
8
|
+
# The packages that will be installed if a venv comes with the template
|
|
9
|
+
BASE_DEPS = ["numpy", "pandas", "matplotlib", "ipykernel"]
|
|
10
|
+
|
|
11
|
+
# Function to create a project template
|
|
12
|
+
def create_project(name: str, template: str, git: bool):
|
|
13
|
+
"""
|
|
14
|
+
Function to create a project template.
|
|
15
|
+
Inputs:
|
|
16
|
+
- name (str): the project/root directory name
|
|
17
|
+
- template (str): the type of template that will be made
|
|
18
|
+
- git (bool): whether to initialize git or not
|
|
19
|
+
"""
|
|
20
|
+
base = Path(name)
|
|
21
|
+
|
|
22
|
+
# Failsafe if a project name already exists in the current directory
|
|
23
|
+
if base.exists():
|
|
24
|
+
raise FileExistsError(f"{name} already exists in the current \
|
|
25
|
+
directory. \nPlease select another project name.")
|
|
26
|
+
|
|
27
|
+
# Creates the empty project folder in the current directory
|
|
28
|
+
base.mkdir()
|
|
29
|
+
|
|
30
|
+
# Copies the desired template (if avaliable)
|
|
31
|
+
template_dir = Path(__file__).parent / "templates" / template
|
|
32
|
+
|
|
33
|
+
if not template_dir.exists():
|
|
34
|
+
raise ValueError(f"Template '{template}' is not avaliable in \
|
|
35
|
+
the templates directory.")
|
|
36
|
+
|
|
37
|
+
# Applies the desired template onto the empty project folder
|
|
38
|
+
shutil.copytree(template_dir, base, dirs_exist_ok=True)
|
|
39
|
+
|
|
40
|
+
# Initializes git (if applicable)
|
|
41
|
+
if git:
|
|
42
|
+
try:
|
|
43
|
+
subprocess.run(
|
|
44
|
+
["git", "init"],
|
|
45
|
+
cwd=base,
|
|
46
|
+
check=True,
|
|
47
|
+
stdout=subprocess.DEVNULL,
|
|
48
|
+
stderr=subprocess.DEVNULL
|
|
49
|
+
)
|
|
50
|
+
print("Successfully initialized a git repository.")
|
|
51
|
+
except FileNotFoundError:
|
|
52
|
+
print("Warning: git is not installed. \
|
|
53
|
+
\nSkipping git initialization.")
|
|
54
|
+
|
|
55
|
+
# Creates a virtual environment (if applicable)
|
|
56
|
+
venv_python = None
|
|
57
|
+
|
|
58
|
+
if template in ["standard", "premium"]:
|
|
59
|
+
try:
|
|
60
|
+
subprocess.run(
|
|
61
|
+
[sys.executable, "-m", "venv", ".venv"],
|
|
62
|
+
cwd=base,
|
|
63
|
+
check=True
|
|
64
|
+
)
|
|
65
|
+
print("Successfully created a virtual environment (.venv)")
|
|
66
|
+
|
|
67
|
+
# detect venv python path (cross-platform)
|
|
68
|
+
if sys.platform == "win32":
|
|
69
|
+
venv_bin = "Scripts/python.exe"
|
|
70
|
+
else:
|
|
71
|
+
venv_bin = "bin/python"
|
|
72
|
+
venv_python = base / ".venv" / venv_bin
|
|
73
|
+
|
|
74
|
+
except subprocess.CalledProcessError:
|
|
75
|
+
print("Warning: failed to create virtual environment. \
|
|
76
|
+
\nSkipping virtual environment setup.")
|
|
77
|
+
|
|
78
|
+
# Setting up dependencies (if applicable)
|
|
79
|
+
if template in ["standard", "premium"]:
|
|
80
|
+
|
|
81
|
+
deps = BASE_DEPS.copy()
|
|
82
|
+
|
|
83
|
+
# install into venv if available,
|
|
84
|
+
# otherwise fallback to system python
|
|
85
|
+
if venv_python and venv_python.exists():
|
|
86
|
+
python_exec = venv_python
|
|
87
|
+
else:
|
|
88
|
+
python_exec = sys.executable
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
subprocess.run(
|
|
92
|
+
[str(python_exec), "-m", "pip", "install", *deps],
|
|
93
|
+
check=True
|
|
94
|
+
)
|
|
95
|
+
print("Successfully installed starter libraries: \
|
|
96
|
+
\n(numpy, pandas, matplotlib, ipykernel)")
|
|
97
|
+
except subprocess.CalledProcessError:
|
|
98
|
+
print("Warning: failed to install starter libraries.")
|
|
99
|
+
|
|
100
|
+
# Creating requirements.txt
|
|
101
|
+
result = subprocess.run(
|
|
102
|
+
[str(python_exec), "-m", "pip", "freeze"],
|
|
103
|
+
capture_output=True,
|
|
104
|
+
text=True,
|
|
105
|
+
check=True
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
req_file = base / "requirements.txt"
|
|
109
|
+
req_file.write_text(result.stdout)
|
|
110
|
+
|
|
111
|
+
print("Successfully generated requirements.txt")
|
|
112
|
+
|
|
113
|
+
# Creating pyproject.toml
|
|
114
|
+
toml_file = base / "pyproject.toml"
|
|
115
|
+
|
|
116
|
+
toml_content = f"""[project]
|
|
117
|
+
name = "{name}"
|
|
118
|
+
version = "0.1.0"
|
|
119
|
+
|
|
120
|
+
dependencies = [
|
|
121
|
+
{chr(10).join(f' "{d}",' for d in deps)}
|
|
122
|
+
]
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
toml_file.write_text(toml_content)
|
|
126
|
+
print("Successfully generated pyproject.toml")
|
|
127
|
+
|
|
128
|
+
print(f"Successfully created project: \
|
|
129
|
+
{name} ({template.upper()} EDITION)")
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Imports
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
# Configurations
|
|
5
|
+
|
|
6
|
+
# ROOT
|
|
7
|
+
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
8
|
+
|
|
9
|
+
# DATA
|
|
10
|
+
DATA_DIR = PROJECT_ROOT / "data"
|
|
11
|
+
RAW_DATA_DIR = DATA_DIR / "raw"
|
|
12
|
+
PROCESSED_DATA_DIR = DATA_DIR / "processed"
|
|
13
|
+
|
|
14
|
+
# FIGURES
|
|
15
|
+
FIGURES_DIR = PROJECT_ROOT / "figures"
|
|
16
|
+
|
|
17
|
+
# LOGS
|
|
18
|
+
LOGS_DIR = PROJECT_ROOT / "logs"
|
|
19
|
+
|
|
20
|
+
# MODELS
|
|
21
|
+
MODELS_DIR = PROJECT_ROOT / "models"
|
|
22
|
+
|
|
23
|
+
# NOTEBOOKS
|
|
24
|
+
NOTEBOOKS_DIR = PROJECT_ROOT / "notebooks"
|
|
25
|
+
|
|
26
|
+
# SRC
|
|
27
|
+
SRC_DIR = PROJECT_ROOT / "src"
|
|
28
|
+
|
|
29
|
+
# WEB
|
|
30
|
+
WEB_DIR = PROJECT_ROOT / "web"
|
|
31
|
+
|
|
32
|
+
# GENERAL SETTINGS
|
|
33
|
+
RANDOM_SEED = 42
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Imports
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pandas as pd
|
|
4
|
+
from matplotlib import pyplot as plt
|
|
5
|
+
|
|
6
|
+
from src import config
|
|
7
|
+
from src import utils
|
|
8
|
+
|
|
9
|
+
# Tests
|
|
10
|
+
def test():
|
|
11
|
+
assert 1 + 1 == 2
|
|
12
|
+
|
|
13
|
+
if __name__ == "__main__":
|
|
14
|
+
test()
|
|
15
|
+
print("All tests passed!")
|
dscforge/utils.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
dscforge/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
dscforge/cli.py,sha256=aRsjfRKEH30raDd15Zc-EdGc-6EI1ksKZBKMP0zwcRE,617
|
|
3
|
+
dscforge/generator.py,sha256=aclELKNOlv6DTB2g1EAsQNcnAkRljZpWGbbU8Qy1-xA,4114
|
|
4
|
+
dscforge/utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
dscforge/templates/basic/main.py,sha256=4ZlqVsrj1REIriQ_NONSpnUAyGfhd0RmalYfWIm8zBA,161
|
|
6
|
+
dscforge/templates/premium/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
dscforge/templates/premium/src/config.py,sha256=ew1cngxKDRLx4P50kPGFB1G_6-nTAtF8xeN58CAjtFo,570
|
|
8
|
+
dscforge/templates/premium/src/main.py,sha256=2IH3okPC-6uV24LTUeP-LGRNENtoLyNfI71cpk6MAGM,229
|
|
9
|
+
dscforge/templates/premium/src/utils.py,sha256=X7JkBWTJXv9CsYujXFY-Kg4DEhxZG5BShJG1zkhPORw,232
|
|
10
|
+
dscforge/templates/premium/tests/test.py,sha256=SuyThZMe-rnd5pcgh7iKHv67rMBB1tbqm3TBC18NZWk,258
|
|
11
|
+
dscforge/templates/standard/src/main.py,sha256=gx0Kibc4s3HmPWVGIAD67XfP6LnX2zrWdl6kWivk5r4,180
|
|
12
|
+
dscforge-0.1.0.dist-info/METADATA,sha256=lU5Cm_DEWi35RhgXgLxcrLDa0GW4dzMzWmdjHsv8ykY,186
|
|
13
|
+
dscforge-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
14
|
+
dscforge-0.1.0.dist-info/entry_points.txt,sha256=UmLCrO6Lc6rfF9hz2KHJYgFalyyJ2kkjNZ-S_ulAtYA,47
|
|
15
|
+
dscforge-0.1.0.dist-info/top_level.txt,sha256=CJN-or8erydJJ6Comfv-WbdzPtktPliNaiUrIxyoVTg,9
|
|
16
|
+
dscforge-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dscforge
|