From dee13fa4f8006d5266c02d6290b0e98d31413a9f Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 7 Dec 2016 14:59:07 +0530 Subject: Refactor code server and python evaluator --- yaksh/language_registry.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'yaksh/language_registry.py') diff --git a/yaksh/language_registry.py b/yaksh/language_registry.py index 0e0140b..8d3aad2 100644 --- a/yaksh/language_registry.py +++ b/yaksh/language_registry.py @@ -14,15 +14,16 @@ def get_registry(): registry = _LanguageRegistry() return registry -def unpack_json(json_data): - data = json.loads(json_data) - return data +# def unpack_json_to_python_obj(json_data): +# data = json.loads(json_data) +# return data -def create_evaluator_instance(language, test_case_type, json_data, in_dir): +def create_evaluator_instance(metadata, test_case): #create_evaluator_instance """Create instance of relevant EvaluateCode class based on language""" registry = get_registry() - cls = registry.get_class(language, test_case_type) - instance = cls(in_dir) + cls = registry.get_class(metadata.get('language'), test_case.get('test_case_type')) + # instance = cls(in_dir) + instance = cls(metadata, test_case) return instance class _LanguageRegistry(object): @@ -36,8 +37,8 @@ class _LanguageRegistry(object): """ Get the code evaluator class for the given language """ if not self._register.get(language): self._register[language] = code_evaluators.get(language) - test_case_register = self._register[language] + cls = test_case_register.get(test_case_type) module_name, class_name = cls.rsplit(".", 1) # load the module, will raise ImportError if module cannot be loaded -- cgit From bf5b4e7607bae0b81ceeb99e8bf5d750433e92e8 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Tue, 20 Dec 2016 12:42:44 +0530 Subject: Fix errors and rename resources - code_evaluator module and class renamed to grader - Test cases fixed - Comments removed - weight variable renamed to mark --- yaksh/language_registry.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'yaksh/language_registry.py') diff --git a/yaksh/language_registry.py b/yaksh/language_registry.py index 8d3aad2..994e9ed 100644 --- a/yaksh/language_registry.py +++ b/yaksh/language_registry.py @@ -14,15 +14,10 @@ def get_registry(): registry = _LanguageRegistry() return registry -# def unpack_json_to_python_obj(json_data): -# data = json.loads(json_data) -# return data - -def create_evaluator_instance(metadata, test_case): #create_evaluator_instance +def create_evaluator_instance(metadata, test_case): """Create instance of relevant EvaluateCode class based on language""" registry = get_registry() cls = registry.get_class(metadata.get('language'), test_case.get('test_case_type')) - # instance = cls(in_dir) instance = cls(metadata, test_case) return instance -- cgit