Skip to content
Snippets Groups Projects
Commit 23c5a685 authored by tuhe's avatar tuhe
Browse files

updates

parent 094375e1
Branches
No related tags found
No related merge requests found
......@@ -16,4 +16,4 @@ diskcache # dashboard
watchdog # dashboard
flask_socketio # dashboard
flask # dashboard
Werkzeug # dashboard
Werkzeug>=2.2.0 # dashboard
Metadata-Version: 2.1
Name: unitgrade
Version: 0.1.30.1
Version: 0.1.30.5
Summary: A student homework/exam evaluation framework build on pythons unittest framework.
Home-page: https://lab.compute.dtu.dk/tuhe/unitgrade
Author: Tue Herlau
......
......@@ -16,6 +16,14 @@ src/unitgrade.egg-info/dependency_links.txt
src/unitgrade.egg-info/entry_points.txt
src/unitgrade.egg-info/requires.txt
src/unitgrade.egg-info/top_level.txt
src/unitgrade/dashboard/__init__.py
src/unitgrade/dashboard/app.py
src/unitgrade/dashboard/app_helpers.py
src/unitgrade/dashboard/dashboard_cli.py
src/unitgrade/dashboard/dbwatcher.py
src/unitgrade/dashboard/ephermaltransfer.py
src/unitgrade/dashboard/file_change_handler.py
src/unitgrade/dashboard/watcher.py
src/unitgrade/dashboard/static/favicon.ico
src/unitgrade/dashboard/static/sidebars.css
src/unitgrade/dashboard/static/sidebars.js
......
# I think this is needed for setup.py
\ No newline at end of file
......@@ -37,6 +37,7 @@ td_classes = {'fail': 'table-danger',
'pass': 'table-success',
'running': 'table-warning',
}
$("#token-blurb").hide();
socket.on("token_update", function(data){
console.log('> Updating token from remote...');
......
......@@ -353,6 +353,7 @@ class UTestCase(unittest.TestCase):
return super().run(result)
from unitgrade.artifacts import StdCapturing
from unitgrade.utils import DKPupDB
self._error_fed_during_run = [] # Initialize this to be empty.
db = DKPupDB(self._artifact_file(), register_ephemeral=True)
db.set("state", "running")
......@@ -530,6 +531,8 @@ class UTestCase(unittest.TestCase):
def __init__(self, *args, skip_remote_check=False, **kwargs):
super().__init__(*args, **kwargs)
# print(f"INIT CALED IN {self}")
self._load_cache()
self._assert_cache_index = 0
# Perhaps do a sanity check here to see if the cache is up to date? To do that, we must make sure the
......@@ -539,15 +542,19 @@ class UTestCase(unittest.TestCase):
return
import importlib, inspect
found_reports = []
# print("But do I have report", self._report)
# print("I think I am module", self.__module__)
# print("Importlib says", importlib.import_module(self.__module__))
good_module_name = self.__module__
try:
importlib.import_module(good_module_name)
except Exception as e:
good_module_name = os.path.basename(good_module_name)[:-3]
# This will delegate you to the wrong main clsas when running in grade mode.
for name, cls in inspect.getmembers(importlib.import_module(self.__module__), inspect.isclass):
# print("checking", cls)
# for name, cls in inspect.getmembers(importlib.import_module(self.__module__), inspect.isclass):
for name, cls in inspect.getmembers(importlib.import_module(good_module_name), inspect.isclass):
if issubclass(cls, Report):
for q,_ in cls.questions:
if q == self.__class__:
if self.__class__.__name__ == q.__name__:
found_reports.append(cls)
if len(found_reports) == 0:
pass # This case occurs when the report _grade script is being run.
......@@ -681,7 +688,14 @@ class UTestCase(unittest.TestCase):
@classmethod
def _cache_file(cls):
return os.path.dirname(inspect.getabsfile(cls)) + "/unitgrade_data/" + cls.__name__ + ".pkl"
# This seems required because python can throw an exception that cls is a 'built-in'(??) when it
# isn't. I don't know what causes it, but it may be the test system.
try:
module_name = inspect.getabsfile(cls)
except Exception as e:
module_name = cls.__module__
return os.path.dirname(module_name) + "/unitgrade_data/" + cls.__name__ + ".pkl"
# return os.path.dirname(inspect.getabsfile(cls)) + "/unitgrade_data/" + cls.__name__ + ".pkl"
@classmethod
def _artifact_file_for_setUpClass(cls):
......@@ -710,6 +724,8 @@ class UTestCase(unittest.TestCase):
if self._cache is not None: # Cache already loaded. We will not load it twice.
return
# raise Exception("Loaded cache which was already set. What is going on?!")
# str(self.__class__)
cfile = self.__class__._cache_file()
if os.path.exists(cfile):
try:
......@@ -843,7 +859,11 @@ class NotebookTestCase(UTestCase):
@classmethod
def setUpClass(cls) -> None:
with Capturing():
cls._nb = importnb.Notebook.load(cls.notebook)
# print(__file__)
f = cls._cache_file()
# print(f)
file = os.path.dirname(os.path.dirname(f)) + "/" + cls.notebook
cls._nb = importnb.Notebook.load_file(file)
@property
def nb(self):
......
......@@ -53,6 +53,8 @@ class Capturing(list):
def __enter__(self, capture_errors=True): # don't put arguments here.
self._stdout = sys.stdout if self._stdout == None else self._stdout
self._stringio = StringIO()
self._stringio_err = StringIO()
if self.unmute:
sys.stdout = Logger(self._stringio)
else:
......@@ -60,7 +62,9 @@ class Capturing(list):
if capture_errors:
self._sterr = sys.stderr
sys.sterr = StringIO() # memory hole it
# sys.sterr = StringIO() # memory hole it
sys.sterr = self._stringio_err
self.capture_errors = capture_errors
return self
......@@ -70,7 +74,7 @@ class Capturing(list):
sys.stdout = self._stdout
if self.capture_errors:
sys.sterr = self._sterr
self.errors = self._stringio_err.getvalue()
class Capturing2(Capturing):
def __exit__(self, *args):
......
__version__ = "0.1.30.2"
\ No newline at end of file
__version__ = "0.1.30.5" \
"" \
""
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment