QuantumChecker 0.3.8__tar.gz → 0.5.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuantumChecker
3
- Version: 0.3.8
3
+ Version: 0.5.0
4
4
  Summary: A package to evaluate homework submissions in Python, SQL, PowerBI, and SSIS.
5
5
  Author: Qobiljon
6
6
  Author-email: qobiljonkhayrullayev@gmail.com
@@ -20,12 +20,27 @@ class HomeworkEvaluator:
20
20
  }
21
21
 
22
22
  EXTENSION_TO_TYPE = {
23
+ #Python
23
24
  ".py": "python",
25
+ ".ipynb": "python",
26
+ ".pyw": "python",
27
+ ".pyi": "python",
28
+ ".pyx": "python",
29
+ ".pxd": "python",
30
+ ".pyd": "python",
31
+ ".so": "python",
32
+
33
+ #SQL
24
34
  ".sql": "sql",
35
+
36
+ #Power BI
25
37
  ".pbit": "powerbi",
26
38
  ".pdf": "powerbi",
39
+
40
+ #SSIS
27
41
  ".dtsx": "ssis",
28
42
  ".DTSX": "ssis",
43
+
29
44
  ".txt": "text",
30
45
  ".md": "text"
31
46
  }
@@ -188,8 +188,22 @@ class PowerBIProcessor:
188
188
  schema_path = os.path.join(export_path, "DataModelSchema")
189
189
  txt_path = os.path.join(export_path, "DataModelSchema.txt")
190
190
  os.rename(schema_path, txt_path)
191
- with open(txt_path, "r", encoding="utf-16-le") as file:
192
- return json.load(file)
191
+ try:
192
+ with open(txt_path, "r", encoding="utf-16-le") as file:
193
+ data = file.read()
194
+ except UnicodeDecodeError:
195
+ with open(txt_path, "r", encoding="utf-16-le", errors="ignore") as file:
196
+ data = file.read()
197
+
198
+ # normalize curly quotes and similar unicode chars
199
+ data = (
200
+ data.replace("’", "'")
201
+ .replace("‘", "'")
202
+ .replace("“", '"')
203
+ .replace("”", '"')
204
+ )
205
+
206
+ return json.loads(data)
193
207
  except UnicodeDecodeError as e:
194
208
  logger.error("Failed to decode DataModelSchema: %s", str(e))
195
209
  raise ProcessingError(f"Invalid encoding in DataModelSchema: {e}")
@@ -84,35 +84,42 @@ def prompt_text_sql(combined_content: str):
84
84
 
85
85
  def prompt_text_ssis(combined_content: str) -> str:
86
86
  return (
87
+
87
88
  "You are an SSIS data engineer evaluating a beginner-level SSIS package submission (1–2 months experience).\n\n"
88
89
  "Evaluation Criteria:\n"
89
90
  "- Assess correct and relevant use of SSIS components: Connection Managers, Control Flow tasks (e.g., Execute SQL Task), Data Flow tasks (e.g., Flat File Source to OLE DB Destination).\n"
91
+ "- Check if the submission attempts to solve the task using SSIS packages (.dtsx) and related concepts.\n"
90
92
  "- Confirm proper linking of components and appropriate use of data types.\n"
91
93
  "- Consider clarity, effort, and completeness.\n"
92
94
  "- If scheduling (e.g., SQL Server Agent Job) is missing, note it but deduct no more than 5 points.\n\n"
95
+ "**STRICT RULE ON OFF-TOPIC SUBMISSIONS:**\n"
96
+ "- If the submission is off-topic (e.g., Python scripts, SQL queries, Power BI reports, or anything NOT an SSIS package or SSIS-related), assign exactly 20/100 points.\n"
97
+ "- Do NOT give any additional points or feedback related to SSIS components.\n"
98
+ "- Clearly state in feedback that the submission does not address the SSIS package requirement and advise focusing on SSIS for this task.\n\n"
93
99
  "Scoring Guidelines:\n"
94
100
  "- Begin with a baseline of 60/100 for any reasonable SSIS attempt.\n"
95
101
  "- Add 5–10 points for extra effort or partial correctness.\n"
96
102
  "- Never exceed 100 points.\n"
97
- "- Always reward genuine effort.\n\n"
98
- "Feedback Format (keep total under 120 words):\n"
103
+ "- Always reward genuine effort unless off-topic.\n\n"
104
+ "Feedback Format:\n"
99
105
  "=== COMPREHENSIVE EVALUATION ===\n"
100
106
  "OVERALL SCORE: <score>/100\n\n"
101
107
  "FEEDBACK SUMMARY:\n"
102
- "- What was done well (1–2 sentences)\n"
103
- "- What needs improvement (1–2 sentences)\n"
104
- "- Major issues (if any, 1 sentence)\n\n"
108
+ "- What was done well\n"
109
+ "- What needs improvement\n"
110
+ "- Major issues (including off-topic comments if applicable)\n\n"
105
111
  "KEY ADVICE:\n"
106
- "- 1–2 improvement tips (1 line each)\n"
112
+ "- 1–2 improvement tips\n"
107
113
  "- Core SSIS concepts to review\n"
108
114
  "- Encouragement to keep practicing\n\n"
109
115
  f"{combined_content}\n"
110
116
  "=== EVALUATION COMPLETE ===\n\n"
111
117
  "Notes:\n"
112
- "- Be concise, clear, and beginner-friendly.\n"
118
+ "- Be kind, clear, and beginner-friendly.\n"
119
+ "- If off-topic, strictly enforce 20/100 score with no exceptions.\n"
120
+ "- Remind student clearly to read the question carefully and focus on SSIS.\n"
113
121
  )
114
122
 
115
-
116
123
  def prompt_text_powerbi(combined_content: str):
117
124
  return (
118
125
  "You are a BI professional evaluating a beginner student's Power BI submission, including DAX, data models, and visuals.\n\n"
@@ -102,6 +102,7 @@ class GeminiFlashModel:
102
102
  class PythonAnswerParser:
103
103
  @staticmethod
104
104
  def parse_single_file(content: str) -> List[str]:
105
+ content = content.replace("’", "'").replace("‘", "'")
105
106
  answers = [a.strip() for a in content.strip().split("\n\n") if a.strip()]
106
107
  if not answers:
107
108
  logger.warning("No valid answers found in single file")
@@ -128,7 +129,11 @@ class PythonAnswerParser:
128
129
  zip_ref.extractall(temp_dir)
129
130
 
130
131
  python_files = sorted(
131
- [f for f in os.listdir(temp_dir) if f.endswith(".py")]
132
+ [
133
+ f
134
+ for f in os.listdir(temp_dir)
135
+ if f.endswith((".py", ".ipynb", ".pyw", ".pyi", ".pyx", ".pxd", ".pyd", ".so"))
136
+ ]
132
137
  )
133
138
 
134
139
  if not python_files:
@@ -140,8 +145,10 @@ class PythonAnswerParser:
140
145
  os.path.join(temp_dir, python_file),
141
146
  "r",
142
147
  encoding="utf-8",
148
+ errors="ignore",
143
149
  ) as f:
144
150
  content = f.read().strip()
151
+ content = content.replace("’", "'").replace("‘", "'")
145
152
  if content:
146
153
  combined_content.append(content)
147
154
 
@@ -102,6 +102,7 @@ class GeminiFlashModel:
102
102
  class SQLAnswerParser:
103
103
  @staticmethod
104
104
  def parse_single_file(content: str) -> List[str]:
105
+ content = content.replace("’", "'").replace("‘", "'")
105
106
  answers = [a.strip() for a in content.strip().split("\n\n") if a.strip()]
106
107
  if not answers:
107
108
  logger.warning("No valid answers found in single file")
@@ -140,8 +141,10 @@ class SQLAnswerParser:
140
141
  os.path.join(temp_dir, sql_file),
141
142
  "r",
142
143
  encoding="utf-8",
144
+ errors="ignore",
143
145
  ) as f:
144
146
  content = f.read().strip()
147
+ content = content.replace("’", "'").replace("‘", "'")
145
148
  if content:
146
149
  combined_content.append(content)
147
150
 
@@ -183,12 +186,26 @@ class SQLEvaluator:
183
186
  """
184
187
  try:
185
188
  if answer_path.endswith(".zip"):
186
- # Use provided temp_dir or generate a default one
187
189
  temp_dir = temp_dir or f"temp_sql_extract_{os.getpid()}"
188
190
  answers = SQLAnswerParser.parse_zip_file(answer_path, temp_dir)
189
191
  else:
190
- with open(answer_path, "r", encoding="utf-8") as file:
191
- content = file.read()
192
+ try:
193
+ with open(answer_path, "r", encoding="utf-8") as file:
194
+ content = file.read()
195
+ except UnicodeDecodeError:
196
+ try:
197
+ with open(answer_path, "r", encoding="cp1252") as file:
198
+ content = file.read()
199
+ except UnicodeDecodeError:
200
+ with open(answer_path, "r", encoding="utf-8", errors="ignore") as file:
201
+ content = file.read()
202
+
203
+ content = (
204
+ content.replace("’", "'")
205
+ .replace("‘", "'")
206
+ .replace("“", '"')
207
+ .replace("”", '"')
208
+ )
192
209
  answers = SQLAnswerParser.parse_single_file(content)
193
210
 
194
211
  logger.info(
@@ -262,9 +262,20 @@ class SSISAnswerParser:
262
262
 
263
263
  for dtsx_file in dtsx_files:
264
264
  file_path = os.path.join(temp_dir, dtsx_file)
265
- with open(file_path, "r", encoding="utf-8") as f:
266
- content = f.read().strip()
267
- if content:
265
+ try:
266
+ with open(file_path, "r", encoding="utf-8") as f:
267
+ content = f.read()
268
+ except UnicodeDecodeError:
269
+ with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
270
+ content = f.read()
271
+
272
+ content = (
273
+ content.replace("’", "'")
274
+ .replace("‘", "'")
275
+ .replace("“", '"')
276
+ .replace("”", '"')
277
+ ).strip()
278
+ if content:
268
279
  parsed_data = SSISAnswerParser.parse_single_file(content)
269
280
  combined_answers.extend(parsed_data.get("text_answers", []))
270
281
  # Merge structured data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: QuantumChecker
3
- Version: 0.3.8
3
+ Version: 0.5.0
4
4
  Summary: A package to evaluate homework submissions in Python, SQL, PowerBI, and SSIS.
5
5
  Author: Qobiljon
6
6
  Author-email: qobiljonkhayrullayev@gmail.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="QuantumChecker",
5
- version="0.3.8",
5
+ version="0.5.0",
6
6
  author="Qobiljon",
7
7
  author_email="qobiljonkhayrullayev@gmail.com",
8
8
  description="A package to evaluate homework submissions in Python, SQL, PowerBI, and SSIS.",
@@ -1,4 +1,6 @@
1
1
  import asyncio
2
+ import os
3
+ import psutil
2
4
  from pprint import pprint
3
5
  from QuantumCheck import HomeworkEvaluator
4
6
 
@@ -6,31 +8,36 @@ API_KEY = "AIzaSyDw76DEINpfBVgwIEZLShhy97tvWg7BmzY"
6
8
 
7
9
  question_sets = {
8
10
  "python": "Write a Python function to calculate factorial.\nWrite a Python script to reverse a string.",
9
- "powerbi": "Create a Power BI report\nExplain DAX measures for sales analysis.",
11
+ "powerbi": "Create a Power BI report with a bar chart.\nExplain DAX measures for sales analysis.",
10
12
  "sql": "Write a SQL query to join two tables.\nWrite a SQL query for aggregate functions.",
11
13
  "ssis": "Design an SSIS package for data import.\nExplain SSIS control flow tasks."
12
14
  }
13
15
 
14
16
  answer_paths = {
15
- "python": ["../tests/answers/second_highest_salary.py"],
16
- "powerbi": ["../tests/answers/random_diagrams.pdf"],
17
- "sql": ["../tests/answers/second_highest_salary.sql"],
18
- "ssis": ["../tests/answers/Package.dtsx"]
17
+ "python": ["../tests/answer/python1.zip"],
18
+ "powerbi": ["../tests/answer/homework2_last.pdf"],
19
+ "sql": ["../tests/answer/sql3.zip"],
20
+ "ssis": ["../tests/answer/answer.dtsx"]
19
21
  }
20
22
 
21
23
  async def main():
22
24
  evaluator = HomeworkEvaluator()
25
+ process = psutil.Process(os.getpid())
23
26
 
24
27
  for qtype, question in question_sets.items():
25
28
  for ans in answer_paths[qtype]:
29
+ mem_before = process.memory_info().rss
26
30
  evaluation = await evaluator.evaluate_from_content(
27
31
  question_content=question,
28
32
  answer_path=ans,
29
33
  api_key=API_KEY,
30
34
  question_type=qtype
31
35
  )
36
+ mem_after = process.memory_info().rss
37
+ delta_mb = (mem_after - mem_before) / 1024**2
32
38
 
33
39
  print(f"{qtype} | {ans}")
40
+ print(f"📈 Memory used for evaluation: {delta_mb:.2f} MB")
34
41
  print(f"✅ Evaluation result: {pprint(evaluation)}")
35
42
  print("-" * 40)
36
43
 
@@ -2,10 +2,10 @@ import asyncio
2
2
  from pprint import pprint
3
3
  from QuantumCheck import HomeworkEvaluator
4
4
 
5
- API_KEY = "AIzaSyDw76DEINpfBVgwIEZLShhy97tvWg7BmzY"
5
+ API_KEY = "AIzaSyDuFmw1Z6qHsQicYsb1XVV7EXPtCj7Kzro"
6
6
 
7
- question = "Create ssis file"
8
- answer_path = "../tests/answers/Package.dtsx"
7
+ question = "Mark the answers below"
8
+ answer_path = "../tests/answers/sample_notebook.ipynb"
9
9
 
10
10
  async def main():
11
11
  evaluator = HomeworkEvaluator()
@@ -13,10 +13,10 @@ async def main():
13
13
  question_content=question,
14
14
  answer_path=answer_path,
15
15
  api_key=API_KEY,
16
- question_type="ssis"
16
+ question_type="python"
17
17
  )
18
18
 
19
- print(f"PowerBI | {answer_path}")
19
+ print(f" | {answer_path}")
20
20
  print("✅ Evaluation result:")
21
21
  pprint(evaluation)
22
22
  print("-" * 40)
File without changes
File without changes