PyKubeGrader 0.2.6__tar.gz → 0.2.8__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. {pykubegrader-0.2.6/src/PyKubeGrader.egg-info → pykubegrader-0.2.8}/PKG-INFO +3 -1
  2. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/setup.cfg +2 -0
  3. {pykubegrader-0.2.6 → pykubegrader-0.2.8/src/PyKubeGrader.egg-info}/PKG-INFO +3 -1
  4. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/PyKubeGrader.egg-info/SOURCES.txt +1 -0
  5. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/PyKubeGrader.egg-info/requires.txt +2 -0
  6. pykubegrader-0.2.8/src/pykubegrader/submit/submit_assignment.py +84 -0
  7. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/.coveragerc +0 -0
  8. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/.github/workflows/main.yml +0 -0
  9. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/.gitignore +0 -0
  10. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/.readthedocs.yml +0 -0
  11. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/AUTHORS.rst +0 -0
  12. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/CHANGELOG.rst +0 -0
  13. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/CONTRIBUTING.rst +0 -0
  14. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/LICENSE.txt +0 -0
  15. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/README.rst +0 -0
  16. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/Makefile +0 -0
  17. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/_static/Drexel_blue_Logo_square_Dark.png +0 -0
  18. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/_static/Drexel_blue_Logo_square_Light.png +0 -0
  19. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/_static/custom.css +0 -0
  20. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/authors.rst +0 -0
  21. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/changelog.rst +0 -0
  22. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/conf.py +0 -0
  23. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/contributing.rst +0 -0
  24. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/index.rst +0 -0
  25. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/license.rst +0 -0
  26. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/readme.rst +0 -0
  27. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/docs/requirements.txt +0 -0
  28. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/examples/.responses.json +0 -0
  29. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/examples/true_false.ipynb +0 -0
  30. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/pyproject.toml +0 -0
  31. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/setup.py +0 -0
  32. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/PyKubeGrader.egg-info/dependency_links.txt +0 -0
  33. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/PyKubeGrader.egg-info/entry_points.txt +0 -0
  34. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/PyKubeGrader.egg-info/not-zip-safe +0 -0
  35. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/PyKubeGrader.egg-info/top_level.txt +0 -0
  36. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/__init__.py +0 -0
  37. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/build/__init__.py +0 -0
  38. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/build/api_notebook_builder.py +0 -0
  39. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/build/build_folder.py +0 -0
  40. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/build/clean_folder.py +0 -0
  41. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/graders/__init__.py +0 -0
  42. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/graders/late_assignments.py +0 -0
  43. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/initialize.py +0 -0
  44. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/log_parser/__init__.py +0 -0
  45. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/log_parser/parse.ipynb +0 -0
  46. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/log_parser/parse.py +0 -0
  47. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/telemetry.py +0 -0
  48. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/utils.py +0 -0
  49. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/validate.py +0 -0
  50. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/__init__.py +0 -0
  51. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/multiple_choice.py +0 -0
  52. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/reading_question.py +0 -0
  53. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/select_many.py +0 -0
  54. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/student_info.py +0 -0
  55. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/style.py +0 -0
  56. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/true_false.py +0 -0
  57. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets/types_question.py +0 -0
  58. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets_base/__init__.py +0 -0
  59. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets_base/multi_select.py +0 -0
  60. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets_base/reading.py +0 -0
  61. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/src/pykubegrader/widgets_base/select.py +0 -0
  62. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/tests/conftest.py +0 -0
  63. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/tests/import_test.py +0 -0
  64. {pykubegrader-0.2.6 → pykubegrader-0.2.8}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyKubeGrader
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -28,6 +28,8 @@ Requires-Dist: types-python-dateutil
28
28
  Requires-Dist: types-pyyaml
29
29
  Requires-Dist: types-requests
30
30
  Requires-Dist: types-setuptools
31
+ Requires-Dist: httpx
32
+ Requires-Dist: nest_asyncio
31
33
  Provides-Extra: testing
32
34
  Requires-Dist: setuptools; extra == "testing"
33
35
  Requires-Dist: pytest; extra == "testing"
@@ -38,6 +38,8 @@ install_requires =
38
38
  types-pyyaml
39
39
  types-requests
40
40
  types-setuptools
41
+ httpx
42
+ nest_asyncio
41
43
 
42
44
  [options.packages.find]
43
45
  where = src
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyKubeGrader
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -28,6 +28,8 @@ Requires-Dist: types-python-dateutil
28
28
  Requires-Dist: types-pyyaml
29
29
  Requires-Dist: types-requests
30
30
  Requires-Dist: types-setuptools
31
+ Requires-Dist: httpx
32
+ Requires-Dist: nest_asyncio
31
33
  Provides-Extra: testing
32
34
  Requires-Dist: setuptools; extra == "testing"
33
35
  Requires-Dist: pytest; extra == "testing"
@@ -46,6 +46,7 @@ src/pykubegrader/graders/late_assignments.py
46
46
  src/pykubegrader/log_parser/__init__.py
47
47
  src/pykubegrader/log_parser/parse.ipynb
48
48
  src/pykubegrader/log_parser/parse.py
49
+ src/pykubegrader/submit/submit_assignment.py
49
50
  src/pykubegrader/widgets/__init__.py
50
51
  src/pykubegrader/widgets/multiple_choice.py
51
52
  src/pykubegrader/widgets/reading_question.py
@@ -13,6 +13,8 @@ types-python-dateutil
13
13
  types-pyyaml
14
14
  types-requests
15
15
  types-setuptools
16
+ httpx
17
+ nest_asyncio
16
18
 
17
19
  [:python_version < "3.8"]
18
20
  importlib-metadata
@@ -0,0 +1,84 @@
1
+ import os
2
+ import httpx
3
+ import asyncio
4
+
5
+ import nest_asyncio
6
+
7
+ nest_asyncio.apply()
8
+
9
+
10
+ def get_credentials():
11
+ """
12
+ Fetch the username and password from environment variables.
13
+ """
14
+ username = os.getenv("user_name_student")
15
+ password = os.getenv("keys_student")
16
+ if not username or not password:
17
+ raise ValueError(
18
+ "Environment variables 'user_name_student' or 'keys_student' are not set."
19
+ )
20
+ return {"username": username, "password": password}
21
+
22
+
23
+ async def call_score_assignment(
24
+ assignment_title: str, file_path: str = ".output_reduced.log"
25
+ ) -> dict:
26
+ """
27
+ Submit an assignment to the scoring endpoint.
28
+
29
+ Args:
30
+ assignment_title (str): Title of the assignment.
31
+ file_path (str): Path to the log file to upload.
32
+
33
+ Returns:
34
+ dict: JSON response from the server.
35
+ """
36
+ # Fetch the endpoint URL from environment variables
37
+ base_url = os.getenv("DB_URL")
38
+ if not base_url:
39
+ raise ValueError("Environment variable 'DB_URL' is not set.")
40
+ url = f"{base_url}score-assignment"
41
+
42
+ # Get credentials
43
+ credentials = get_credentials()
44
+
45
+ # Send the POST request
46
+ async with httpx.AsyncClient() as client:
47
+ try:
48
+ with open(file_path, "rb") as file:
49
+ response = await client.post(
50
+ url,
51
+ data={"cred": credentials, "assignment_title": assignment_title},
52
+ files={"log_file": file},
53
+ )
54
+
55
+ # Handle the response
56
+ response.raise_for_status() # Raise an exception for HTTP errors
57
+ response_data = response.json()
58
+ return response_data
59
+ except FileNotFoundError:
60
+ raise FileNotFoundError(f"The file {file_path} does not exist.")
61
+ except httpx.RequestError as e:
62
+ raise RuntimeError(f"An error occurred while requesting {url}: {e}")
63
+ except Exception as e:
64
+ raise RuntimeError(f"An unexpected error occurred: {e}")
65
+
66
+
67
+ # Importable function
68
+ def submit_assignment(
69
+ assignment_title: str, file_path: str = ".output_reduced.log"
70
+ ) -> None:
71
+ """
72
+ Synchronous wrapper for the `call_score_assignment` function.
73
+
74
+ Args:
75
+ assignment_title (str): Title of the assignment.
76
+ file_path (str): Path to the log file to upload.
77
+ """
78
+ response = asyncio.run(call_score_assignment(assignment_title, file_path))
79
+ print("Server Response:", response.get("message", "No message in response"))
80
+
81
+
82
+ # Example usage (remove this section if only the function needs to be importable):
83
+ if __name__ == "__main__":
84
+ submit_assignment("Week 1 Assignment", "path/to/your/log_file.txt")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes