Skip to content

Commit f582302

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 235b429 + 9791307 commit f582302

14 files changed

+759
-42
lines changed

.idea/SQL_Template.iml

+7-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/csv-editor.xml

+8-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dataSources.xml

+10-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Folder_watchdog.py

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ def csv_order_collection():
5757
time.sleep(10)
5858

5959

60+
def TODO_scanner():
61+
62+
6063
if __name__ == "__main__":
6164
USER_NAME = environ.get("USER_NAME")
6265
directory_path = f"/Users/" f"{USER_NAME}/sbox/PycharmProjects/SQL_Template/data/"

Project_Template.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
1. Uniform project setup
2+
1.1 use cookie cutter for template of each project
3+
2.
4+
3. log your results, taipy for logging, input and outputs
5+
3.1 toml
6+
3.2 papertrail cloud service
7+
3.3 commet perfomance tool
8+
4. data intermediate setups data science projects, preprocessing
9+
4.1 csv and json data setups, micro problems data queries in database
10+
5. move to code i plan on reusing to a shared package,
11+
5.1 reusing code in jupyternotebook, create a package
12+
5.2 add unittest
13+
5.3 add style testing
14+
5.4 abstract into package_name.sub_function(parameter1, param2)
15+
6. move configurations settings to a seperate file
16+
6.1 yaml file
17+
6.2 toml file
18+
6.3 env file **
19+
6.4 cfg file taipy etc
20+
7. Pycharm defualt settinsg, requirements.txt, black, youtrack, linting
21+
8. Write unittest, coverage tests banners in readme.md

TODO_scanner.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# TODO_scanner.py
2+
# SOURCE
3+
4+
5+
import os
6+
import csv
7+
8+
9+
def scan_todo_tags():
10+
"""creates a CSV file named todo_tags.csv under the data/ folder and writes the following information for each TODO tag found
11+
:param file_name: The name of the file containing the TODO tag
12+
:param project_name: The name of the project (which is the same as the file
13+
name without the .py extension)
14+
:param tag_FOUND: The TODO tag found (e.g., TODO, FIXME, #TODO)
15+
:param tag_message: The message following the TODO tag
16+
:param date_added: The date the TODO tag was added to the file (using the file's creation time)
17+
:param user: The username of the user running the script (using the os.environ.get('USERNAME') function call)
18+
:param
19+
20+
"""
21+
22+
cwd = os.getcwd()
23+
24+
# Create the CSV file and write the header
25+
with open("data/todo_tags.csv", "w", newline="") as csvfile:
26+
writer = csv.writer(csvfile)
27+
writer.writerow(
28+
["file_name", "project_name", "tag_FOUND", "tag_message", "date_added", "user"]
29+
)
30+
31+
# Loop through all files in the current directory
32+
for file_name in os.listdir(cwd):
33+
# Only check Python files
34+
if file_name.endswith(".py"):
35+
# Get the project name
36+
project_name = file_name.split(".")[0]
37+
38+
# Open the file and loop through each line
39+
with open(file_name, "r") as f:
40+
for i, line in enumerate(f):
41+
# Check for TODO tags
42+
if "TODO" in line or "FIXME" in line or "#TODO" in line:
43+
# Get the tag message and date added
44+
tag_message = line.strip()
45+
date_added = os.path.getctime(file_name)
46+
47+
# Write the information to the CSV file
48+
writer.writerow(
49+
[
50+
file_name,
51+
project_name,
52+
line[: line.find(tag_message)],
53+
tag_message,
54+
date_added,
55+
os.environ.get("USERNAME"),
56+
]
57+
)

main.py

+23-21
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def print_hi(user_name):
3232
:return:
3333
"""
3434
# global user_name
35-
print(f'Hi, {user_name}') # Press ⌘F8 to toggle the breakpoint.
35+
print(f"Hi, {user_name}") # Press ⌘F8 to toggle the breakpoint.
3636
return user_name
3737

3838

@@ -41,14 +41,14 @@ def which_database():
4141
Get users preference for database
4242
:return:
4343
"""
44-
POSTGRESQL = 'postgress11'
45-
MYSQL = 'mysql8'
46-
SQLITE3 = 'sqlite3'
47-
SQLSERVER = 'sqlserver17'
48-
ORACLE = 'oracle11'
49-
AWS = 'RDS'
50-
NOSQL = 'salesforce'
51-
44+
POSTGRESQL = "postgress_12"
45+
MYSQL = "mysql_08"
46+
SQLITE3 = "sqlite_03"
47+
SQLSERVER = "sqlserver_17"
48+
ORACLE = "oracle_11"
49+
AWS = "RDS_09"
50+
NOSQL = "salesforce_02"
51+
5252
# TODO use the terms from each database
5353
# TODO print(f'Hi, {user_name} what database do you want to work with?')
5454
# TODO print(f'Do you prefer')
@@ -62,6 +62,7 @@ def gpu_exist_active():
6262
"""
6363
# SOURE https://dask-sql.readthedocs.io/en/latest/
6464
import dask.datasets
65+
6566
# TODO error ""
6667
print("cuda gpu support available but not installed 'import dask_cudf'")
6768

@@ -75,14 +76,16 @@ def gpu_exist_active():
7576
c.create_table("timeseries", df, gpu=True)
7677

7778
# execute a SQL query; the result is a "lazy" Dask dataframe
78-
result = c.sql("""
79+
result = c.sql(
80+
"""
7981
SELECT
8082
name, SUM(x) as "sum"
8183
FROM
8284
timeseries
8385
GROUP BY
8486
name
85-
""")
87+
"""
88+
)
8689

8790
# actually compute the query...
8891
result.compute()
@@ -92,7 +95,6 @@ def gpu_exist_active():
9295
pass
9396

9497

95-
9698
def create_environment():
9799
"""
98100
function to create and populate .env file
@@ -106,23 +108,23 @@ def create_environment():
106108
# TODO prompt user for database packages, pandas, numpy, matplotlib, seaborn
107109
# TODO prompt user for database POSTGRESQL, SQLITE, MYSQL, SQLSERVER, ORACLE, AWS, NOSQL
108110
print("create_environment function pass")
109-
111+
110112

111113
# Press the green button in the gutter to run the script.
112-
if __name__ == '__main__':
113-
USER_NAME = environ.get('USER_NAME')
114+
if __name__ == "__main__":
115+
USER_NAME = environ.get("USER_NAME")
114116
confirm_user_name = input(f"Hello your first name is {USER_NAME}?")
115117
# TODO add yes/no option else
116118
# TODO grep day time greetings based on morning, night etc
117119
# TODO prompt user for user name
118-
print_hi('Greetings, PyCharm has run')
119-
120+
print_hi("Greetings, PyCharm has run")
121+
120122
# Find .env file
121123
basedir = path.abspath(path.dirname(__file__))
122-
load_dotenv(path.join(basedir, '.env'))
124+
load_dotenv(path.join(basedir, ".env"))
123125

124126
# General Config
125-
SECRET_KEY = environ.get('SECRET_KEY')
126-
FLASK_APP = environ.get('FLASK_APP')
127-
FLASK_ENV = environ.get('FLASK_ENV')
127+
SECRET_KEY = environ.get("SECRET_KEY")
128+
FLASK_APP = environ.get("FLASK_APP")
129+
FLASK_ENV = environ.get("FLASK_ENV")
128130
main()

model/chatbot/SQL_chatbot.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# SOURCE
22
import csv
33

4+
5+
# TODO move to within main at bottom
46
FILENAME = "../../data/movies.txt"
57
CSV_FILENAME = "../../data/movies.csv"
68

@@ -51,7 +53,7 @@ def write_movies(movies):
5153

5254
def read_movies():
5355
"""
54-
open FILENAME and read each line as a new movie
56+
open FILENAME and read each line as a new movie
5557
:return:
5658
"""
5759
movies = []
@@ -74,7 +76,9 @@ def list_movies(movies):
7476
print()
7577

7678

77-
def add_movie(movie):
79+
# TODO OALETF rollbar is underappreciated
80+
# https://rollbar.com/blog/python-attributeerror/
81+
def add_movie(movies):
7882
"""
7983
add a movie to end of list
8084
:param movies:
@@ -84,11 +88,16 @@ def add_movie(movie):
8488
movie.append(movie)
8589
write_movies(movies)
8690
print(movie + " was added.\n")
91+
i = 1
92+
try:
93+
i.append(2)
94+
except AttributeError:
95+
print("No such attribute")
8796

8897

8998
def delete_movie(movies):
9099
"""
91-
delete movie by number
100+
delete movie by number
92101
:param movies:
93102
:return:
94103
"""
@@ -100,7 +109,7 @@ def delete_movie(movies):
100109

101110
def display_menu():
102111
"""
103-
display the menu on screen
112+
display the menu on screen
104113
:return:
105114
"""
106115
print("The Movie List Program")

0 commit comments

Comments
 (0)