internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: hedyorg/hedy

Issue:
[BUG] Missing page title for class statistics
**Describe the bug**
We fix a page title for the class statistics page, therefore the fallback title "Hedy" is used.



Discussion:

Resolving patch:
diff --git a/website/statistics.py b/website/statistics.py
--- a/website/statistics.py
+++ b/website/statistics.py
@@ -1,5 +1,7 @@
 from collections import namedtuple
 from flask import request, jsonify
+
+import hedyweb
 from flask_helpers import render_template
 from website.auth import requires_login, is_admin, is_teacher
 
@@ -28,7 +30,8 @@ def render_class_stats(user, class_id):
         if not class_ or (class_['teacher'] != user['username'] and not is_admin(user)):
             return utils.error_page(error=404, ui_message='no_such_class')
 
-        return render_template('class-stats.html', class_info={'id': class_id})
+        return render_template('class-stats.html', class_info={'id': class_id},
+                               current_page='my-profile', page_title=hedyweb.get_page_title('class statistics'))
 
     @app.route('/class-stats/<class_id>', methods=['GET'])
     @requires_login
diff --git a/website/teacher.py b/website/teacher.py
--- a/website/teacher.py
+++ b/website/teacher.py
@@ -60,7 +60,7 @@ def get_class (user, class_id):
         teachers = os.getenv('BETA_TEACHERS', '').split(',')
         is_beta_teacher = user['username'] in teachers
 
-        return render_template ('class-overview.html', current_page='for-teachers',
+        return render_template ('class-overview.html', current_page='my-profile',
                                 page_title=hedyweb.get_page_title('class overview'),
                                 achievement=achievement,
                                 is_beta_teacher=is_beta_teacher,
@@ -210,7 +210,7 @@ def get_class_info(user, class_id):
 
         return render_template('customize-class.html', page_title=hedyweb.get_page_title('customize class'),
                                class_info={'name': Class['name'], 'id': Class['id']}, levels=levels,
-                               adventures=adventures, preferences=preferences, current_page='for-teachers')
+                               adventures=adventures, preferences=preferences, current_page='my-profile')
 
     @app.route('/customize-class/<class_id>', methods=['PUT'])
     @requires_login


Test patch:
Repository: hedyorg/hedy

Issue:
[BUG] Unexpected result when printing variable names in level 5
In some cases when I print a variable name between quotes in level 5 it is replaced by the variable value. I wouldn't expect this as the variable name is between quotes. This only happens when the variable name is the only name between quotes and not when there is other text within the quotes.

```
naam is 'Daan'
woord1 is zomerkamp
print 'naam' ' is naar het' 'woord1'
print 'naam is naar het woord1'
```
![image](https://user-images.githubusercontent.com/10562903/150997661-cd2c16ed-9f72-4f6d-b47f-1c063c63e358.png)



Discussion:
Interesting!! That clearly should not be the case. I will dive into this, I am suspecting it is something small, like a wrong fallback to a lower level.

Resolving patch:
diff --git a/hedy.py b/hedy.py
--- a/hedy.py
+++ b/hedy.py
@@ -1336,8 +1336,9 @@ def print_ask_args(self, args):
         args = self.check_var_usage(args)
         result = ''
         for argument in args:
+            argument = self.process_variable_for_fstring(argument)
             argument = argument.replace("'", '')  # no quotes needed in fstring
-            result += self.process_variable_for_fstring(argument)
+            result += argument
         return result
 
     def print(self, args):


Test patch:
diff --git a/tests/test_level_05.py b/tests/test_level_05.py
--- a/tests/test_level_05.py
+++ b/tests/test_level_05.py
@@ -12,6 +12,19 @@ class TestsLevel5(HedyTester):
   # is
 
 
+  def test_print_var_1795(self):
+    code = textwrap.dedent("""\
+    naam is 'Daan'
+    woord1 is zomerkamp
+    print 'naam' ' is naar het' 'woord1'""")
+
+    expected = textwrap.dedent("""\
+    naam = '\\'Daan\\''
+    woord1 = 'zomerkamp'
+    print(f'naam is naar hetwoord1')""")
+
+    self.single_level_tester(code=code, expected=expected)
+
   def test_assign_list_multiple_spaces(self):
     code = textwrap.dedent("""\
     dieren is Hond,  Kat,       Kangoeroe
Repository: hedyorg/hedy

Issue:
[BUG] Explore UI not consistent with latest changes
**Describe the bug**
With the latest changes the UI of the Explore page is not consistent.

**Add a screenshot (optional)**
![Schermafbeelding 2022-01-25 om 22 06 11](https://user-images.githubusercontent.com/38155424/151059802-f8588042-a590-4ee8-9bd8-4e4651395194.png)

**Expected behavior**
The "view program" button is always in the same spot and visible. The username always fits on one line.


Discussion:

Resolving patch:
diff --git a/app.py b/app.py
--- a/app.py
+++ b/app.py
@@ -1234,15 +1234,22 @@ def explore():
     else:
         programs = DATABASE.get_all_explore_programs()
 
+    filtered_programs = []
     for program in programs:
-        program['code'] = "\n".join(program['code'].split("\n")[:4])
+        filtered_programs.append({
+            'username': program['username'],
+            'name': program['name'],
+            'level': program['level'],
+            'id': program['id'],
+            'code': "\n".join(program['code'].split("\n")[:4])
+        })
 
     if hedy_content.Adventures(session['lang']).has_adventures():
         adventures = hedy_content.Adventures(session['lang']).get_adventure_keyname_name_levels()
     else:
         adventures = hedy_content.Adventures("en").get_adventure_keyname_name_levels()
 
-    return render_template('explore.html', programs=programs,
+    return render_template('explore.html', programs=filtered_programs,
                            filtered_level=level,
                            achievement=achievement,
                            filtered_adventure=adventure,


Test patch:
Repository: hedyorg/hedy

Issue:
Add program language to the stats pages log search results
The language of the program is already in Athena and is present in the query response. What's left is to add a column in the front-end.


Discussion:

Resolving patch:
diff --git a/app.py b/app.py
--- a/app.py
+++ b/app.py
@@ -726,11 +726,12 @@ def query_logs():
 
     class_id = body.get('class_id')
     if not is_admin(user):
-        if not class_id:
+        username_filter = body.get('username')
+        if not class_id or not username_filter:
             return 'unauthorized', 403
 
         class_ = DATABASE.get_class(class_id)
-        if not class_ or class_['teacher'] != user['username'] or body.get('username') not in class_.get('students'):
+        if not class_ or class_['teacher'] != user['username'] or username_filter not in class_.get('students', []):
             return 'unauthorized', 403
 
     (exec_id, status) = log_fetcher.query(body)
diff --git a/website/statistics.py b/website/statistics.py
--- a/website/statistics.py
+++ b/website/statistics.py
@@ -30,7 +30,8 @@ def render_class_stats(user, class_id):
         if not class_ or (class_['teacher'] != user['username'] and not is_admin(user)):
             return utils.error_page(error=404, ui_message='no_such_class')
 
-        return render_template('class-stats.html', class_info={'id': class_id, 'students': sorted(class_['students'])},
+        students = sorted(class_.get('students', []))
+        return render_template('class-stats.html', class_info={'id': class_id, 'students': students},
                                current_page='my-profile', page_title=hedyweb.get_page_title('class statistics'))
 
     @app.route('/class-stats/<class_id>', methods=['GET'])
@@ -40,10 +41,11 @@ def get_class_stats(user, class_id):
         end_date = request.args.get('end', default=None, type=str)
 
         cls = DATABASE.get_class(class_id)
-        if not cls or (cls['teacher'] != user['username'] and not is_admin(user)):
-            return utils.error_page(error=403, ui_message='no_such_class')
+        students = cls.get('students', [])
+        if not cls or not students or (cls['teacher'] != user['username'] and not is_admin(user)):
+            return 'No such class or class empty', 403
 
-        data = DATABASE.get_class_program_stats(cls['students'], start_date, end_date)
+        data = DATABASE.get_class_program_stats(students, start_date, end_date)
 
         per_level_data = _aggregate_for_keys(data, [level_key])
         per_week_data = _aggregate_for_keys(data, [week_key, level_key])


Test patch:
Repository: ESMCI/cime

Issue:
Debug new xmlquery
./create_test cime_developer has issues.



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/case.py b/utils/python/CIME/case.py
--- a/utils/python/CIME/case.py
+++ b/utils/python/CIME/case.py
@@ -154,8 +154,6 @@ def get_values(self, item=None, attribute={}, resolved=True, subgroup=None):
         # Empty result list
         results = []
 
-        if item in self.lookups.keys():
-            results = [self.lookups[item]]
 
         for env_file in self._files:
             # Wait and resolve in self rather than in env_file


Test patch:
Repository: ESMCI/cime

Issue:
Misleading error message in case_setup.py 
I suggest changing "%s NINST value %d greater than %s NTASKS %d" 
(e.g ERROR: ATM NINST value 1 greater than ATM NTASKS 0)

to 

"NINST_%s value %d greater than NTASKS_%s %d
(e.g. ERROR: NINST_ATM value 1 greater than NTASKS_ATM 0)

to reflect the real variable name which can be queried or changed with xmlquery/xmlchange



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/case_setup.py b/utils/python/CIME/case_setup.py
--- a/utils/python/CIME/case_setup.py
+++ b/utils/python/CIME/case_setup.py
@@ -166,7 +166,7 @@ def case_setup(case, clean=False, test_mode=False, reset=False):
                 if ntasks == 1:
                     case.set_value("NTASKS_%s" % comp, ninst)
                 else:
-                    expect(False, "%s NINST value %d greater than %s NTASKS %d" % (comp, ninst, comp, ntasks))
+                    expect(False, "NINST_%s value %d greater than NTASKS_%s %d" % (comp, ninst, comp, ntasks))
 
         expect(not (case.get_value("BUILD_THREADED") and case.get_value("COMPILER") == "nag"),
                "it is not possible to run with OpenMP if using the NAG Fortran compiler")


Test patch:
Repository: ESMCI/cime

Issue:
Remove ESMF from driver code



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/SystemTests/pfs.py b/utils/python/CIME/SystemTests/pfs.py
--- a/utils/python/CIME/SystemTests/pfs.py
+++ b/utils/python/CIME/SystemTests/pfs.py
@@ -18,7 +18,7 @@ def __init__(self, case):
         SystemTestsCommon.__init__(self, case)
 
     def run(self):
-        self._case_set_value("STOP_OPTION", "ndays")
+        self._case.set_value("STOP_OPTION", "ndays")
         self._case.set_value("STOP_N", 20)
         self._case.set_value("REST_OPTION","none")
         self._case.set_value("CONTINUE_RUN", False)
diff --git a/utils/python/CIME/preview_namelists.py b/utils/python/CIME/preview_namelists.py
--- a/utils/python/CIME/preview_namelists.py
+++ b/utils/python/CIME/preview_namelists.py
@@ -72,9 +72,12 @@ def preview_namelists(case, dryrun=False, casedir=None):
         cmd = os.path.join(config_dir, "buildnml")
         logger.info("Running %s"%cmd)
         if (logger.level == logging.DEBUG):
-            run_cmd("PREVIEW_NML=1 %s %s" % (cmd, caseroot))
+            rc, out, err = run_cmd("PREVIEW_NML=1 %s %s" % (cmd, caseroot), ok_to_fail=True)
+            expect(rc==0,"Command %s failed rc=%d\nout=%s\nerr=%s"%(cmd,rc,out,err))
         else:
-            run_cmd("%s %s" % (cmd, caseroot))
+            rc, out, err = run_cmd("%s %s" % (cmd, caseroot), ok_to_fail=True)
+            expect(rc==0,"Command %s failed rc=%d\nout=%s\nerr=%s"%(cmd,rc,out,err))
+
     # refresh case xml object from file
     case.read_xml(caseroot)
     # Save namelists to docdir


Test patch:
Repository: ESMCI/cime

Issue:
Allow debugging prints to output
Adding "print" commands to perl build scripts don't show up.



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/preview_namelists.py b/utils/python/CIME/preview_namelists.py
--- a/utils/python/CIME/preview_namelists.py
+++ b/utils/python/CIME/preview_namelists.py
@@ -68,14 +68,14 @@ def preview_namelists(case, dryrun=False):
         config_file = case.get_value("CONFIG_%s_FILE" % model_str.upper())
         config_dir = os.path.dirname(config_file)
         cmd = os.path.join(config_dir, "buildnml")
-        logger.info("Running %s"%cmd)
+        logger.info("Running %s:"%cmd)
         if (logger.level == logging.DEBUG):
             rc, out, err = run_cmd("PREVIEW_NML=1 %s %s" % (cmd, caseroot))
-            expect(rc==0,"Command %s failed rc=%d\nout=%s\nerr=%s"%(cmd,rc,out,err))
+            expect(rc==0,"Command %s failed rc=%d\nout=%s\nerr=%s"%(cmd,rc,out,err))      
         else:
             rc, out, err = run_cmd("%s %s" % (cmd, caseroot))
             expect(rc==0,"Command %s failed rc=%d\nout=%s\nerr=%s"%(cmd,rc,out,err))
-
+        logger.info("     %s"%out)
     # refresh case xml object from file
     case.read_xml()
     # Save namelists to docdir


Test patch:
diff --git a/utils/python/tests/scripts_regression_tests.py b/utils/python/tests/scripts_regression_tests.py
--- a/utils/python/tests/scripts_regression_tests.py
+++ b/utils/python/tests/scripts_regression_tests.py
@@ -39,8 +39,8 @@ def do_unit_tests(self, script,from_dir=SCRIPT_DIR):
         stat, output, _ = run_cmd("./%s --test 2>&1" % script, from_dir=from_dir)
         self.assertEqual(stat, 0, msg=output)
 
-    def test_acme_bisect_unit_test(self):
-        self.do_unit_tests("acme_bisect",from_dir=TOOLS_DIR)
+    def test_cime_bisect_unit_test(self):
+        self.do_unit_tests("cime_bisect",from_dir=TOOLS_DIR)
 
     def test_compare_namelists_unit_test(self):
         self.do_unit_tests("compare_namelists",from_dir=TOOLS_DIR)
Repository: ESMCI/cime

Issue:
Wasn't warned about old python version on edison
I had the default python version on edison (2.6.9) and "create_newcase" didn't give me a helpful error message:

edison04 cimeESMCI/scripts> ./create_newcase -case Xcase3 -compset X -res f19_g16 -mach edison -compiler intel -project acme
Traceback (most recent call last):
  File "./create_newcase", line 3, in <module>
    from Tools.standard_script_setup import *
  File "/global/u2/r/rjacob/cimeESMCI/scripts/Tools/standard_script_setup.py", line 15, in <module>
    import CIME.utils
  File "/global/u2/r/rjacob/cimeESMCI/scripts/Tools/../../utils/python/CIME/utils.py", line 6, in <module>
    from importlib import import_module
ImportError: No module named importlib



Discussion:

Resolving patch:
diff --git a/scripts/Tools/standard_script_setup.py b/scripts/Tools/standard_script_setup.py
--- a/scripts/Tools/standard_script_setup.py
+++ b/scripts/Tools/standard_script_setup.py
@@ -3,7 +3,7 @@
 that every script should do.
 """
 
-import sys, os, logging, doctest, argparse
+import sys, os
 import __main__ as main
 _CIMEROOT = os.environ.get("CIMEROOT")
 if(_CIMEROOT is None):
@@ -15,3 +15,5 @@
 import CIME.utils
 CIME.utils.check_minimum_python_version(2, 7)
 CIME.utils.stop_buffering_output()
+
+import logging, doctest, argparse
diff --git a/utils/python/CIME/utils.py b/utils/python/CIME/utils.py
--- a/utils/python/CIME/utils.py
+++ b/utils/python/CIME/utils.py
@@ -3,7 +3,6 @@
 Warning: you cannot use CIME Classes in this module as it causes circular dependencies
 """
 import logging, gzip, sys, os, time, re, shutil
-from importlib import import_module
 
 # Return this error code if the scripts worked but tests failed
 TESTS_FAILED_ERR_CODE = 100
@@ -219,7 +218,7 @@ def check_minimum_python_version(major, minor):
     >>>
     """
     expect(sys.version_info[0] == major and sys.version_info[1] >= minor,
-           "Python %d, minor verion %d+ is required, you have %d.%d" %
+           "Python %d, minor version %d+ is required, you have %d.%d" %
            (major, minor, sys.version_info[0], sys.version_info[1]))
 
 def normalize_case_id(case_id):
@@ -882,6 +881,8 @@ def find_system_test(testname, case):
     path to that directory to sys.path if its not there and return the test object
     Fail if the test is not found in any of the paths.
     '''
+    from importlib import import_module
+
     system_test_path = None
     if testname.startswith("TEST"):
         system_test_path =  "CIME.SystemTests.system_tests_common.%s"%(testname)


Test patch:
Repository: ESMCI/cime

Issue:
TestStatus.log file cluttered with "Already had input file" messages
Using something like cime5.0.5 in the cesm alpha01 tag, running ERS_Ld7.f10_f10.ICLM45.yellowstone_gnu, my TestStatus.log file is full of messages like this one:

```
Already had input file: '/glade/p/cesmdata/cseg/inputdata/atm/datm7/atm_forcing.datm7.Qian.T62.c080727/Solar6Hrly/clmforc.Qian.c2006.T62.Solr.1972-01.nc'
```

I see this is from:

```
utils/python/CIME/check_input_data.py:112:                        logging.info("Already had input file: '%s'" % full_path)
```

Would it be reasonable to change this output to only appear if a higher logging level is requested? Or do others prefer to have this verbose output of what input files are found?



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/check_input_data.py b/utils/python/CIME/check_input_data.py
--- a/utils/python/CIME/check_input_data.py
+++ b/utils/python/CIME/check_input_data.py
@@ -109,7 +109,7 @@ def check_input_data(case, svn_loc=None, input_data_root=None, data_list_dir="Bu
                                 no_files_missing = False
 
                     else:
-                        logging.info("Already had input file: '%s'" % full_path)
+                        logging.debug("Already had input file: '%s'" % full_path)
 
                 else:
                     model = os.path.basename(data_list_file).split('.')[0]


Test patch:
Repository: ESMCI/cime

Issue:
component_compare_baseline.sh broken for pop model
This script is looking for pop.h files but pop has several flavors of this file and this is causing baseline failures.   For example SMS_Ld7.f09_g16.B1850.yellowstone_intel.allactive-cesm2dev01io
creates pop history files: 
SMS_Ld7.f09_g16.B1850.yellowstone_intel.allactive-cesm2dev01io.GC.a1d_int.pop.h.ecosys.nday1.0001-01-02.nc
SMS_Ld7.f09_g16.B1850.yellowstone_intel.allactive-cesm2dev01io.GC.a1d_int.pop.h.nday1.0001-01-02.nc
SMS_Ld7.f09_g16.B1850.yellowstone_intel.allactive-cesm2dev01io.GC.a1d_int.pop.h.once.nc

but only one of these is copied to the baseline directory with the --generate option and the wrong one is compared with the --compare option.   



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/user_mod_support.py b/utils/python/CIME/user_mod_support.py
--- a/utils/python/CIME/user_mod_support.py
+++ b/utils/python/CIME/user_mod_support.py
@@ -23,11 +23,12 @@ def apply_user_mods(caseroot, user_mods_path, ninst=None):
 
     include_dirs = build_include_dirs_list(user_mods_path)
     for include_dir in include_dirs:
-
         # write user_nl_xxx file in caseroot
         for user_nl in glob.iglob(os.path.join(include_dir,"user_nl_*")):
             with open(os.path.join(include_dir, user_nl), "r") as fd:
                 newcontents = fd.read()
+            if len(newcontents) == 0:
+                continue
             case_user_nl = user_nl.replace(include_dir, caseroot)
             comp = case_user_nl.split('_')[-1]
             if ninst is not None and comp in ninst.keys():


Test patch:
Repository: ESMCI/cime

Issue:
module list for tcsh and csh users 
The module list command in env_mach_specific.py does not work for tcsh and csh users
I've commented out the call to this code in case_setup.py until the problem can be resolved.
Code was added in PR 337



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/XML/env_mach_specific.py b/utils/python/CIME/XML/env_mach_specific.py
--- a/utils/python/CIME/XML/env_mach_specific.py
+++ b/utils/python/CIME/XML/env_mach_specific.py
@@ -93,14 +93,23 @@ def load_modules(self, modules_to_load):
             expect(False, "Unhandled module system '%s'" % module_system)
 
     def list_modules(self):
-        import subprocess
         module_system = self.get_module_system_type()
+
+        # If the user's login shell is not sh, it's possible that modules
+        # won't be configured so we need to be sure to source the module
+        # setup script if it exists.
+        init_path = self.get_module_system_init_path("sh")
+        if init_path:
+            source_cmd = "source %s && " % init_path
+        else:
+            source_cmd = ""
+
         if (module_system == "module"):
-            return run_cmd_no_fail("module list", arg_stderr=subprocess.STDOUT)
+            return run_cmd_no_fail("%smodule list 2>&1" % source_cmd)
         elif (module_system == "soft"):
-            return run_cmd_no_fail("softenv")
+            return run_cmd_no_fail("%ssoftenv" % source_cmd)
         elif (module_system == "dotkit"):
-            return run_cmd_no_fail("use -lv")
+            return run_cmd_no_fail("%suse -lv" % source_cmd)
         elif (module_system == "none"):
             return ""
         else:
diff --git a/utils/python/CIME/case_setup.py b/utils/python/CIME/case_setup.py
--- a/utils/python/CIME/case_setup.py
+++ b/utils/python/CIME/case_setup.py
@@ -286,11 +286,10 @@ def _case_setup_impl(case, caseroot, casebaseid, clean=False, test_mode=False, r
         env_module = case.get_env("mach_specific")
         env_module.make_env_mach_specific_file(compiler, debug, mpilib, "sh")
         env_module.make_env_mach_specific_file(compiler, debug, mpilib, "csh")
-# FIXME This code is not working with tcsh and csh users using modules
-#        with open("software_environment.txt", "w") as f:
-#            f.write(env_module.list_modules())
-#        run_cmd_no_fail("echo -e '\n' >> software_environment.txt && \
-#                         env >> software_environment.txt")
+        with open("software_environment.txt", "w") as f:
+            f.write(env_module.list_modules())
+        run_cmd_no_fail("echo -e '\n' >> software_environment.txt && \
+                         env >> software_environment.txt")
 
 ###############################################################################
 def case_setup(case, clean=False, test_mode=False, reset=False):


Test patch:
Repository: ESMCI/cime

Issue:
Allow replacement of config_compilers.xml with config_build.xml
This is an improvement on the xml schema that we want in cime5.1 



Discussion:

Resolving patch:
diff --git a/utils/python/CIME/case.py b/utils/python/CIME/case.py
--- a/utils/python/CIME/case.py
+++ b/utils/python/CIME/case.py
@@ -710,8 +710,11 @@ def _create_caseroot_tools(self):
 
         # Create Macros file.
         machine = self.get_value("MACH")
-        if os.getenv("CIME_USE_CONFIG_BUILD") == "TRUE":
-            files = Files()
+        files = Files()
+        # Use config_build if the environment variable is set, or if there is no
+        # config_compilers file.
+        if os.getenv("CIME_USE_CONFIG_BUILD") == "TRUE" or \
+           files.get_value("COMPILERS_SPEC_FILE") is None:
             build_file = files.get_value("BUILD_SPEC_FILE")
             machobj = Machines(machine=machine, files=files)
             macro_maker = Build(machobj)


Test patch: