anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: yashaka/selene
Issue: After manually quitting, setting a new driver fails

Selene version: 2.0.0a21

I quit my current driver using `browser.quit()`.
Then, I create a new driver and set it, which runs the following method:
```
@driver.setter
    def driver(self, value: WebDriver):
        stored = self._source.value
        is_another_driver = on_error_return_false(lambda: value.session_id != stored.session_id)

        if is_another_driver:
            stored.quit()  # todo: can quit raise exception? handle then...

        self._source.put(value)

        self.browser_name = value and value.name  # overwrites default browser_name
```
The problem is, that the quit() method doesn't remove the driver object, and thus the session id will differ. Because of this, `is_another_driver` will be `True` and thus `stored.quit()` will fail throwing a `selenium.common.exceptions.WebDriverException: Message: Session timed out or not found`.

Suggested fix:
Either change the condition for `is_another_driver` or make `quit()` nullify the `session_id`.

Changed files:
selene/support/shared/config.py, selene/support/shared/browser.py

diff --git a/selene/support/shared/browser.py b/selene/support/shared/browser.py
index a8821adb..8a75c122 100644
--- a/selene/support/shared/browser.py
+++ b/selene/support/shared/browser.py
@@ -121,6 +121,10 @@ class SharedBrowser(Browser):
         warnings.warn('browser.latest_page_source prop is deprecated, use browser.last_page_source', DeprecationWarning)
         return self.config.last_page_source
 
+    def quit(self) -> None:
+        super().quit()
+        self.config.reset_source()
+
     def quit_driver(self):
         warnings.warn('deprecated; use browser.quit() instead', DeprecationWarning)
         self.quit()
diff --git a/selene/support/shared/config.py b/selene/support/shared/config.py
index 9eaddfdb..ba156ed4 100644
--- a/selene/support/shared/config.py
+++ b/selene/support/shared/config.py
@@ -219,6 +219,9 @@ PageSource: file://{path}''')
         hook = self._inject_screenshot_and_page_source_pre_hooks(self.hook_wait_failure)
         return Wait(entity, at_most=self.timeout, or_fail_with=hook)
 
+    def reset_source(self):
+        self._source = Source()
+
     # --- Config.* added setters --- #
 
     @Config.timeout.setter
Repository: learningequality/kolibri
Issue: Catch ValueError during network discovery for when JSON parsing fails

<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior
<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->

When trying to import content channels (from local network or internet), no error message is produced even though the connection isn't established. (The "trying to connect" message stays on forever) This happens when there is a typo in the address. (I used kolibri-demo.learningequality.omg)  When there's no internet, an error message DOES get produced. 

### Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

An error message should've been produced.

### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

The user will not know how long they have to wait to see if the connection is being established.

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

…

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

Import content channels from local network or internet >input "kolibri-demo.learningequality.omg" or something else with a typo in it.

### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

Kolibri version: 0.14.3
Operating system: Android 5.1
Browser: Android App
Device: BLU Advance 5.0


Changed files:
kolibri/core/discovery/utils/network/client.py

diff --git a/kolibri/core/discovery/utils/network/client.py b/kolibri/core/discovery/utils/network/client.py
index 431e6dac03..727906f572 100644
--- a/kolibri/core/discovery/utils/network/client.py
+++ b/kolibri/core/discovery/utils/network/client.py
@@ -55,6 +55,10 @@ class NetworkClient(object):
                     return response.url.rstrip("/").replace("api/public/info", "")
             except (requests.RequestException) as e:
                 logger.info("Unable to connect: {}".format(e))
+            except ValueError:
+                logger.info(
+                    "Invalid JSON returned when attempting to connect to a remote server"
+                )
 
         # we weren't able to connect to any of the URL variations, so all we can do is throw
         raise errors.NetworkLocationNotFound()
Repository: learningequality/kolibri
Issue: Cannot update DeviceSettings

## Observed behavior
Reported by @nucleogenesis [in the alpha13 bug bash ](https://www.notion.so/learningequality/Cannot-update-DeviceSettings-24859b98d15b411a8c55b83cddebc6d6?pvs=4)

> I tried to change a device setting, but it failed due to (it seems) a bad or unexpected value for secondary_storage_... 


## Context
0.16.0-a13


Changed files:
kolibri/utils/filesystem.py

diff --git a/kolibri/utils/filesystem.py b/kolibri/utils/filesystem.py
index 59e9215f1f..7d19e43c1f 100644
--- a/kolibri/utils/filesystem.py
+++ b/kolibri/utils/filesystem.py
@@ -36,6 +36,9 @@ def resolve_path(path):
     :param path: Path to expand and resolve
     :return: The resolved path.
     """
+    if not path:  # Check if the path is empty
+        return path
+
     try:
         return os.path.realpath(os.path.expanduser(path))
     except (IOError, OSError):
Repository: learningequality/kolibri
Issue: Mac app - Cannot save the changes made at Device > Settings

## Observed behavior
Nothing happens when I click the 'Save changes' button at Device > Settings

## Expected behavior
All changes made should be saved.

## Steps to reproduce the issue
1. Install the [v0.16.0-beta1](https://github.com/learningequality/kolibri/releases/tag/v0.16.0-beta1) 
2. Go to Device > Settings
3. Click the 'Save changes' button

## Video

https://github.com/learningequality/kolibri/assets/79847249/4c695726-8a5a-4250-b9ca-25583e5762ac

## Logs

[logs.zip](https://github.com/learningequality/kolibri/files/12309862/logs.zip)

## Usage Details
Kolibri 0.16.0b1
MacOS Catalina version 10.15.7

Changed files:
kolibri/plugins/utils/__init__.py

diff --git a/kolibri/plugins/utils/__init__.py b/kolibri/plugins/utils/__init__.py
index c5147a407e..64b7eac109 100644
--- a/kolibri/plugins/utils/__init__.py
+++ b/kolibri/plugins/utils/__init__.py
@@ -474,7 +474,7 @@ def check_plugin_config_file_location(version):
 def iterate_plugins():
     # Use to dedupe plugins
     plugin_ids = set()
-    for entry_point in entry_points()["kolibri.plugins"]:
+    for entry_point in entry_points().get("kolibri.plugins", []):
         name = entry_point.name
         if name not in plugin_ids:
             plugin_ids.add(name)
Repository: learningequality/kolibri
Issue: When starting Exams, Notifications and Attempt logs can be out of sync


### Observed behavior

1. As a learner, start an exam, but do not do any of the questions
1. After some time, a Notification will be recorded for the exam with a status of "Started"
1. However, querying the class summary API, the 'exam learner status' for that exam will have a status of "NotStarted".

This can lead to an inconsistency, where the Notification will update the in-memory classSummary data and cause the dashboard and reports to show that 1 learner has "started" an exam, but if you were to refresh (and get the on-server class summary data without the updating notification), it will revert to showing 0 learners starting the exam.

### Expected behavior

Since, the UI intends to use Notifications to patch class summary in real time, the two notions of "Exam Started" should match to avoid situations like the on described above.


### User-facing consequences

inconsistent / fluctuating values in reports


### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context

0.12.0 a 7

Changed files:
kolibri/plugins/coach/class_summary_api.py

diff --git a/kolibri/plugins/coach/class_summary_api.py b/kolibri/plugins/coach/class_summary_api.py
index 3165251f01..b2227295db 100644
--- a/kolibri/plugins/coach/class_summary_api.py
+++ b/kolibri/plugins/coach/class_summary_api.py
@@ -108,9 +108,8 @@ class ExamStatusSerializer(serializers.ModelSerializer):
     def get_status(self, exam_log):
         if exam_log.closed:
             return COMPLETED
-        elif exam_log.attemptlogs.values_list("item").count() > 0:
+        else:
             return STARTED
-        return NOT_STARTED
 
     def get_num_correct(self, exam_log):
         return (
Repository: learningequality/kolibri
Issue: Enable ePUB plugin to run by default


### Observed behavior

ePUB plugin is not enabled by default, and it prevents from importing & viewing ePUB files, until the command `kolibri plugin kolibri.plugins.document_epub_render enable` is run.

### User-facing consequences
Inability to view and import ePUB files.


### Context
dev environment, tried on `develop` and `0.11.a7` branches


Changed files:
kolibri/utils/conf.py

diff --git a/kolibri/utils/conf.py b/kolibri/utils/conf.py
index dd308d001b..0576a182b5 100644
--- a/kolibri/utils/conf.py
+++ b/kolibri/utils/conf.py
@@ -68,6 +68,7 @@ except ImportError:
         "kolibri.plugins.user",
         "kolibri_exercise_perseus_plugin",
         "kolibri.plugins.style_guide",
+        "kolibri.plugins.document_epub_render",
     ]
 
 #: Everything in this list is added to django.conf.settings.INSTALLED_APPS
Repository: learningequality/kolibri
Issue: Very long, CPU-intensive process after asking to import selected Khan Academy resources

### Observed behavior

Need more info on this, but this is the best I can produce right now.. observe the 566m of CPU usage:

```
top - 01:39:58 up 2 days, 11:30,  1 user,  load average: 2.10, 2.17, 2.17
Tasks: 287 total,   1 running, 286 sleeping,   0 stopped,   0 zombie
%Cpu(s): 45.6 us, 12.9 sy,  0.0 ni, 41.5 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8054696 total,   904492 free,  5504828 used,  1645376 buff/cache
KiB Swap: 16381948 total, 14482384 free,  1899564 used.  1499508 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                            
15123 kolibri   20   0 3474360 1.112g  10440 S 201.0 14.5 566:35.82 kolibri                         
```

### Steps to reproduce

Not sure, but I have asked to download a select sub-part of the KA resources, and my laptop is stuck for hours.


### Context

Kolibri 0.9.0, debian installation source, Ubuntu 16.04


Changed files:
kolibri/content/management/commands/importcontent.py

diff --git a/kolibri/content/management/commands/importcontent.py b/kolibri/content/management/commands/importcontent.py
index 8964fe70ae..f5be4ab783 100644
--- a/kolibri/content/management/commands/importcontent.py
+++ b/kolibri/content/management/commands/importcontent.py
@@ -67,7 +67,7 @@ class Command(AsyncCommand):
         parser.add_argument(
             "--include-unrenderable-content",
             action='store_false',
-            default=True,
+            default=False,
             dest="renderable_only",
             help="Import all content, not just that which this Kolibri instance can render"
         )
Repository: learningequality/kolibri
Issue: Translatable strings are not being properly updated on devserver

## Summary

- Sometimes tr strings that are modified do not get properly updated.

## System information

 - Version: 0.6
 - Operating system: Ubuntu
 - Node 6.11.2

## How to reproduce

1. Try editing tr strings and check that they are updated in the UI. Pretty random.

## Real-life consequences 

- Development rage 

Changed files:
kolibri/core/webpack/hooks.py

diff --git a/kolibri/core/webpack/hooks.py b/kolibri/core/webpack/hooks.py
index 257ea9c632..1d623a97e8 100644
--- a/kolibri/core/webpack/hooks.py
+++ b/kolibri/core/webpack/hooks.py
@@ -236,7 +236,7 @@ class WebpackBundleHook(hooks.KolibriHook):
     def frontend_messages(self):
         global _JSON_MESSAGES_FILE_CACHE
         lang_code = get_language()
-        if not _JSON_MESSAGES_FILE_CACHE.get(self.unique_slug, {}).get(lang_code):
+        if not _JSON_MESSAGES_FILE_CACHE.get(self.unique_slug, {}).get(lang_code) or django_settings.DEBUG:
             frontend_message_file = self.frontend_message_file(lang_code)
             if frontend_message_file:
                 with open(frontend_message_file) as f:
Repository: learningequality/kolibri
Issue: ping command fails: TypeError: float() argument must be a string or a number

### Observed behavior

I think this fails silently in its own thread. Happened on Python 2.7, not sure why, but traceback is easy to fix.

### Expected behavior

n/a

### User-facing consequences

None, but ping doesn't happen

### Errors and logs

```
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/media/archive/code/kolibri/kolibri/utils/server.py", line 98, in run
    call_command("ping")
  File ".virtualenvs/kolibri/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 131, in call_command
    return command.execute(*args, **defaults)
  File ".virtualenvs/kolibri/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/media/archive/code/kolibri/kolibri/core/analytics/management/commands/ping.py", line 34, in handle
    interval = float(options.get("interval", DEFAULT_PING_INTERVAL))
TypeError: float() argument must be a string or a number

```


### Steps to reproduce

Sorry can't say for sure, was just reading a log.

### Context

Tell us about your environment, including:
 * Kolibri version: Either 0.7 or `develop` :)
 * Operating system: The best linux distro version 16.04
 * Browser: n/a


Changed files:
kolibri/core/analytics/management/commands/ping.py

diff --git a/kolibri/core/analytics/management/commands/ping.py b/kolibri/core/analytics/management/commands/ping.py
index 3fc5451523..7feaa19a9b 100644
--- a/kolibri/core/analytics/management/commands/ping.py
+++ b/kolibri/core/analytics/management/commands/ping.py
@@ -31,9 +31,9 @@ class Command(BaseCommand):
 
     def handle(self, *args, **options):
 
-        interval = float(options.get("interval", DEFAULT_PING_INTERVAL))
-        checkrate = float(options.get("checkrate", DEFAULT_PING_CHECKRATE))
-        server = options.get("server", DEFAULT_PING_SERVER_URL)
+        interval = float(options.get("interval") or DEFAULT_PING_INTERVAL)
+        checkrate = float(options.get("checkrate") or DEFAULT_PING_CHECKRATE)
+        server = options.get("server") or DEFAULT_PING_SERVER_URL
 
         self.started = datetime.now()
Repository: learningequality/kolibri
Issue: possible for task queue to be locked up

### Observed behavior

When server starts, task queue might have items in it even if there are none running

### Expected behavior

task queue should be cleared when server starts

### User-facing consequences

Incorrect view of server state and potentially blocked from performing actions

### Steps to reproduce

(Is this correct?)

* start server
* start loading channel metadata
* kill server
* start server

### Context

* Kolibri version: 0.7 beta


Changed files:
kolibri/utils/server.py

diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
index 497f8ffd11..ffe1a4c66f 100644
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -68,6 +68,11 @@ def start(port=8080):
     from kolibri.content.utils.annotation import update_channel_metadata
     update_channel_metadata()
 
+    # This is also run every time the server is started to clear all the tasks
+    # in the queue
+    from kolibri.tasks.client import get_client
+    get_client().clear(force=True)
+
     def rm_pid_file():
         os.unlink(PID_FILE)
Repository: learningequality/kolibri
Issue: partially-complete transfers prevent a successful upgrade

### Observed behavior

If Kolibri 0.6 is shut down while a transfer is in progress, running Kolibri 0.7 won't work

### Expected behavior

Upgrades should occur smoothly. Preferably the transfer can pick up where it left off, but if it needs to be canceled that's the next best solution.

### User-facing consequences

Kolibri is not usable after attempting to upgrade.

### Errors and logs

lots of this:

```
ERROR    Internal Server Error: /api/tasks/
Traceback (most recent call last):
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/rest_framework/viewsets.py", line 87, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch
    response = self.handle_exception(exc)
  File "/Users/d/PythonEnvs/le2/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch
    response = handler(request, *args, **kwargs)
  File "kolibri/tasks/api.py", line 42, in list
    jobs_response = [_job_to_response(j) for j in get_client().all_jobs()]
  File "kolibri/tasks/api.py", line 427, in _job_to_response
    "type": job.extra_metadata.get("type"),
AttributeError: 'Job' object has no attribute 'extra_metadata'
```

### Steps to reproduce

* start up 0.6
* start a long-running import
* shut down 0.6 before import completes
* start up 0.7


### Context

* Kolibri version: 0.6 -> 0.7
* Operating system: OSX


Changed files:
kolibri/tasks/api.py

diff --git a/kolibri/tasks/api.py b/kolibri/tasks/api.py
index affaac1a57..e72f56a62d 100644
--- a/kolibri/tasks/api.py
+++ b/kolibri/tasks/api.py
@@ -424,8 +424,8 @@ def _job_to_response(job):
         }
     else:
         return {
-            "type": job.extra_metadata.get("type"),
-            "started_by": job.extra_metadata.get("started_by"),
+            "type": getattr(job, "extra_metadata", {}).get("type"),
+            "started_by": getattr(job, "extra_metadata", {}).get("started_by"),
             "status": job.state,
             "exception": str(job.exception),
             "traceback": str(job.traceback),
Repository: learningequality/kolibri
Issue: Inaccurate reporting of installer when using DEB

### Observed behavior

After installing the DEB on Ubuntu, I went to Device -> Info, and the "Installer" field showed "whl".

### Expected behavior

Should show something like "deb".

### User-facing consequences

When users report issues to us, we may make different suggestions/interpretations based on what installer was used. This could lead us astray here.

It also throws off nutritionfacts stats.

### Errors and logs

```
Version:           0.14.0rc1
OS:                Linux-5.3.0-7648-generic-x86_64-with-Ubuntu-19.10-eoan
Python:            3.7.5
Installer:         whl
Server:            Kolibri internal server
Database:          /home/jamalex/.kolibri/db.sqlite3
Free disk space:   344 GB
Server time:       Thu Aug 06 2020 13:48:38 GMT-0700 (Pacific Daylight Time)
Server timezone:   America/Los_Angeles
```


Changed files:
kolibri/utils/server.py

diff --git a/kolibri/utils/server.py b/kolibri/utils/server.py
index 86ebd1ca68..f3607112da 100644
--- a/kolibri/utils/server.py
+++ b/kolibri/utils/server.py
@@ -549,13 +549,14 @@ def installation_type(cmd_line=None):  # noqa:C901
         try:
             check_output(["apt-cache", "show", "kolibri"])
             apt_repo = str(check_output(["apt-cache", "madison", "kolibri"]))
-            if apt_repo:
+            if len(apt_repo) > 4:  # repo will have at least http
                 install_type = "apt"
         except (
             CalledProcessError,
             FileNotFoundError,
         ):  # kolibri package not installed!
-            install_type = "whl"
+            if sys.path[-1] != "/usr/lib/python3/dist-packages":
+                install_type = "whl"
         return install_type
 
     def is_kolibri_server():
Repository: learningequality/kolibri
Issue: Delete channel or resources task fails when attempting to release an expired Redis lock


### Observed behavior
Both `Delete channel` and `Manage > Delete (all) resources` for that same channel are failing. 
Asset from `v0.14.4-weekly7` build on Windows 7.
The only content present was **KA (EN) > Math > Arithmetic**, and I was not able to delete neither the full channel, nor by selecting all the resources inside, as the task was reported as `Failed`. I suspect just the DB was deleted but not the resources.

### Expected behavior
Being able to delete channel/resources.

### User-facing consequences
Inability to manage channels and resources on the device.

### Errors and logs

Nothing jumped at me as relevant in the browser console, attaching the logs.

[logs.zip](https://github.com/learningequality/kolibri/files/5497727/logs.zip)


### Steps to reproduce
1. Download **KA (EN) > Math > Arithmetic**.
2. Try to delete the channel and/or all the resources.

### Context

Tell us about your environment, including:
 * Kolibri version: v0.14.4-weekly7
 * Operating system: Windows 7
 * Browser: Firefox



Changed files:
kolibri/core/utils/cache.py

diff --git a/kolibri/core/utils/cache.py b/kolibri/core/utils/cache.py
index c23672e622..3194e97d1f 100644
--- a/kolibri/core/utils/cache.py
+++ b/kolibri/core/utils/cache.py
@@ -61,7 +61,12 @@ class ProcessLock(object):
         self._lock.acquire()
 
     def release(self):
-        self._lock.release()
+        try:
+            self._lock.release()
+        except AssertionError:
+            logger.warning(
+                "Got an AssertionError when releasing a lock! This is likely from the lock TTL expiring."
+            )
 
     def __enter__(self):
         self.acquire()
Repository: learningequality/kolibri
Issue: Subquery in `FaclityViewset` `last_synced` annotation can return multiple results

<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior

This subquery from the `TransferSession` table can return multiple results, which causes the `/api/auth/facility` endpoint to  break

https://github.com/learningequality/kolibri/blob/release-v0.14.x/kolibri/core/auth/api.py#L359

### Expected behavior

The `/api/auth/facility` endpoint doesn't break because of this query. The subquery should be limited to a returning a single value.

### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

…

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

…

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

…

### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

…


Changed files:
kolibri/core/auth/api.py

diff --git a/kolibri/core/auth/api.py b/kolibri/core/auth/api.py
index 695786901b..5c36a4f269 100644
--- a/kolibri/core/auth/api.py
+++ b/kolibri/core/auth/api.py
@@ -366,7 +366,7 @@ class FacilityViewSet(ValuesViewset):
                         )
                     )
                     .order_by("-last_activity_timestamp")
-                    .values("last_activity_timestamp")
+                    .values("last_activity_timestamp")[:1]
                 )
             )
         )
Repository: learningequality/kolibri
Issue: Importing more content (or deleting resources) to a channel undoes its original position in channel list

<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior

~Similar to #5292, if you import more content to a channel, it will always be moved to the bottom of the Device > Channel page even if you had given it a different order (or didn't reorder it but just imported it in the past at some point). Because a lot of places in the app use the same order, we also see #5292~

Edit: This has been resolved for Kolibri when using Sqlite, but when using Postgresl, what seems to happen is that the newly modified channel goes to the _top_ of the list. It's because the channel in this case falls into this branch:

https://github.com/learningequality/kolibri/blob/0ee38838e5fc74d1f85b15c867f53ec4c261448c/kolibri/core/content/utils/annotation.py#L479-L482

~A somewhat mitigating factor is that newly updated channels will temporarily be moved to the top of the channel and have a green "New" label attached to it, so it will be easy to find immediately after the import.~

### Expected behavior

Updating a channel doesn't move it to the ~"bottom"~ top of the channel list.

### User-facing consequences

1. Users will need to move the channel again
1. Users might not immediately realize the channel moved 

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/logs/kolibri.txt
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

…

### Steps to reproduce
1. Run Kolibri using Postgresql as DB
1. Run a similar scenario as described above

### Context
Kolibri 0.13

Changed files:
kolibri/core/content/utils/annotation.py

diff --git a/kolibri/core/content/utils/annotation.py b/kolibri/core/content/utils/annotation.py
index f06a9c1e09..c2c6f3d092 100644
--- a/kolibri/core/content/utils/annotation.py
+++ b/kolibri/core/content/utils/annotation.py
@@ -478,6 +478,8 @@ def calculate_next_order(channel, model=ChannelMetadata):
     latest_order = model.objects.latest("order").order
     if latest_order is None:
         channel.order = 1
-    else:
+
+    if channel.order is None or channel.order == 0:
         channel.order = latest_order + 1
+
     channel.save()
Repository: learningequality/kolibri
Issue: Exporting CSV file that contains Unicode text fails on Python 3 on Windows

### Observed behavior
User reports of CSV file export failing prompted me to add a test for this in a Windows environment in https://github.com/learningequality/kolibri/pull/7899.

When Unicode text should be inserted into the exported CSV, such as a Unicode username or full_name, then an error occurs on windows.

```
Error trying to write csv file: 'charmap' codec can't encode characters in position 29-35: character maps to <undefined>
```

### Expected behavior
CSV Export should work on all platforms.

This is fixed by this commit: https://github.com/learningequality/kolibri/pull/7899/commits/c088d08b3e6c4a0f4194a17062457cbd7ae34816

### User-facing consequences
Windows users are unable to export CSV files.


Changed files:
kolibri/core/logger/csv_export.py

diff --git a/kolibri/core/logger/csv_export.py b/kolibri/core/logger/csv_export.py
index 0e2ff6c9ff..6526e9ae2b 100644
--- a/kolibri/core/logger/csv_export.py
+++ b/kolibri/core/logger/csv_export.py
@@ -154,7 +154,7 @@ def csv_file_generator(facility, log_type, filepath, overwrite=False):
     if sys.version_info[0] < 3:
         csv_file = io.open(filepath, "wb")
     else:
-        csv_file = io.open(filepath, "w", newline="")
+        csv_file = io.open(filepath, "w", newline="", encoding="utf-8")
 
     with csv_file as f:
         writer = csv.DictWriter(f, header_labels)
Repository: frictionlessdata/framework
Issue: Wrong stats on repeated attempts of read after transform

Frictionless version: 5.10.1

# Overview

Attempts to read lines from a transformed CSV files fail after initial exhaustion (either via `read_rows` or just running `validate` on it).

# Steps to reproduce

Consider the following CSV file:
```
a,b
1,2
```

And the following code snippet:
```
import frictionless
from frictionless import Pipeline, Resource, steps
r = Resource("test.csv")
print(len(r.read_rows()))  # 1
print(len(r.read_rows()))  # 1
r2 = frictionless.transform(r, pipeline=Pipeline(steps=[steps.field_pack(name="test", from_names=["a"], as_object=True)]))
print(len(r2.read_rows()))  # 1
print(len(r2.read_rows()))  # 0
print(len(r.read_rows()))  # 0
```

I'd expect the number of rows to remain the same until the very end.

In general, I  have encountered issues with regards to rows disappearing after basic transformations, perhaps some test cases need to be added to address this? :thinking: 


Changed files:
frictionless/steps/field/field_pack.py, tests/steps/field/test_field_pack.py

diff --git a/frictionless/steps/field/field_pack.py b/frictionless/steps/field/field_pack.py
index 022179f9..23998129 100644
--- a/frictionless/steps/field/field_pack.py
+++ b/frictionless/steps/field/field_pack.py
@@ -56,7 +56,7 @@ class field_pack(Step):
             for name in self.from_names:
                 resource.schema.remove_field(name)
         processor = iterpackdict if self.as_object else iterpack  # type: ignore
-        resource.data = processor(table, self.name, self.from_names, self.preserve)
+        resource.data = list(processor(table, self.name, self.from_names, self.preserve))
 
     # Metadata
 
diff --git a/tests/steps/field/test_field_pack.py b/tests/steps/field/test_field_pack.py
index a71fa61a..936b952a 100644
--- a/tests/steps/field/test_field_pack.py
+++ b/tests/steps/field/test_field_pack.py
@@ -77,3 +77,15 @@ def test_step_field_pack_object():
         "population": 83,
         "details": {"name": "germany", "population": "83"},
     }
+
+
+def test_step_field_pack_retain_data():
+    source = TableResource(path="data/transform.csv")
+    pipeline = Pipeline(
+        steps=[
+            steps.field_pack(name="details", from_names=["name", "population"]),
+        ],
+    )
+    target = source.transform(pipeline)
+    assert len(target.read_rows()) == 3
+    assert len(target.read_rows()) == 3
Repository: zalando-incubator/kubernetes-on-aws
Issue: Updating a cluster leads to API server downtime

First observation: the ELB healthcheck leads to ASG terminating a new instance because the `HealthCheckGracePeriod` defaults to 5 minutes and the master node sometimes takes longer than 5 minutes to come up :disappointed: 


Changed files:
cluster/cluster.py

diff --git a/cluster/cluster.py b/cluster/cluster.py
index 4acc7075..57a71e54 100755
--- a/cluster/cluster.py
+++ b/cluster/cluster.py
@@ -344,13 +344,20 @@ def drain_node(node_name: str, config: dict, max_grace_period=60):
     # respect pod terminate grace period
     grace_period = min(longest_grace_period(node_name, config), max_grace_period)
 
-    subprocess.check_call([
-        'kubectl',
-        '--server', config["api_server"],
-        '--token', config["worker_shared_secret"],
-        'drain', node_name,
-        '--force', '--delete-local-data',
-        '--grace-period={}'.format(grace_period)])
+    for i in range(3):
+        try:
+            subprocess.check_call([
+                'kubectl',
+                '--server', config["api_server"],
+                '--token', config["worker_shared_secret"],
+                'drain', node_name,
+                '--force', '--delete-local-data',
+                '--ignore-daemonsets',
+                '--grace-period={}'.format(grace_period)])
+            break
+        except Exception as e:
+            warning('Kubectl failed to drain node: {}'.format(e))
+            time.sleep(grace_period)
     time.sleep(grace_period)
Repository: danforthcenter/plantcv
Issue: sample_images function does not output line returns

**Describe the bug**
`pcv.utils.sample_images` on line 42 does not include a line return character, so all rows in `SnapshotInfo.csv` are written out on one line. The code should be:

```python
out_file.write(','.join(row) + "\\n")
```


Changed files:
plantcv/utils/sample_images.py

diff --git a/plantcv/utils/sample_images.py b/plantcv/utils/sample_images.py
index d99ad344..7605e861 100644
--- a/plantcv/utils/sample_images.py
+++ b/plantcv/utils/sample_images.py
@@ -39,7 +39,7 @@ def sample_images(source_path, dest_path, num=100):
         random_index = random.sample(range(0, len(line_array) - 1), num)
         for i in random_index:
             row = line_array[int(i)]
-            out_file.write(','.join(row))
+            out_file.write(','.join(row) + "\\n")
             snap_path = os.path.join(source_path, "snapshot" + row[1])
             folder_path = os.path.join(dest_path, "snapshot" + row[1])
             if not os.path.exists(folder_path):
Repository: danforthcenter/plantcv
Issue: pcv.hyperspectral.analyze_index summary statistics need help handling different datatypes 

**Describe the bug**
It was noticed that some of the summary statistics being saved during `pcv.hyperspectral.analyze_index` are NaN (funky data values within different indices means that we need to be able to handle values like infinity).  

**To Reproduce**
Reported while running the ARI index through the analyze_index function.

**Expected behavior**
Be able to measure mean/median/stdev regardless of which index is being analyzed. 


**Ideas for moving forward**
- replace with versions of the function that are able to handle NAs, and also consider masking out bad/problematic pixels before analysis. Allow users to provide a mask for bad pixels but if not provided, then mask out pixels within the function. 

Changed files:
plantcv/plantcv/hyperspectral/analyze_index.py

diff --git a/plantcv/plantcv/hyperspectral/analyze_index.py b/plantcv/plantcv/hyperspectral/analyze_index.py
index d4a3f59c..b77a858d 100644
--- a/plantcv/plantcv/hyperspectral/analyze_index.py
+++ b/plantcv/plantcv/hyperspectral/analyze_index.py
@@ -47,9 +47,11 @@ def analyze_index(index_array, mask, histplot=False, bins=100, min_bin=0, max_bi
 
     # Mask data and collect statistics about pixels within the masked image
     masked_array = index_array.array_data[np.where(mask > 0)]
-    index_mean = np.average(masked_array)
-    index_median = np.median(masked_array)
-    index_std = np.std(masked_array)
+    masked_array = masked_array[np.isfinite(masked_array)]
+
+    index_mean = np.nanmean(masked_array)
+    index_median = np.nanmedian(masked_array)
+    index_std = np.nanstd(masked_array)
 
     # Set starting point and max bin values
     maxval = max_bin
Repository: danforthcenter/plantcv
Issue: Utility sample_images does not sample from image snapshots only

**Describe the bug**
The `sample_images` method in `plantcv-utils.py` when working with "Phenofront" data (datasets with a `SnapshotInfo.csv` file) does not differentiate between snapshots (rows in the spreadsheet) that have images and those that do not (e.g. watering events). Because there can be many more watering events than imaging events, any given random sample can be light on actual image data. We can update the function slightly to randomly subset from only image data.



Changed files:
plantcv/utils/sample_images.py

diff --git a/plantcv/utils/sample_images.py b/plantcv/utils/sample_images.py
index 1de23a1f..783fc226 100644
--- a/plantcv/utils/sample_images.py
+++ b/plantcv/utils/sample_images.py
@@ -23,8 +23,10 @@ def sample_images(source_path, dest_path, num=100):
         input_csv = open(os.path.join(source_path, 'SnapshotInfo.csv'))
         header = input_csv.readline()
         for line in input_csv:
+            line = line.rstrip("\\n")
             element_arr = line.split(',')
-            line_array.append(element_arr)
+            if element_arr[-1]:
+                line_array.append(element_arr)
         input_csv.close()
 
         # Check to make sure number of imgs to select is less than number of images found
Repository: myremylar/pygame_gui
Issue: set_text_hidden function of UITextEntryLine does not hide already entered symbols

**Describe the bug**
When calling set_text_hidden(True) on a non-empty UITextEntryLine component it will not update already entered text to become hidden, instead only newly entered symbols will be hidden. 

**To Reproduce**
Steps to reproduce the behaviour:
1. Add a new UITextEntryLine component to the UIManager
2. Create a button which executes set_text_hidden(True)
3. Enter text in UITextEntryLine
4. Press button to hide text

**Expected behaviour**
I expect already typed text to become hidden by displaying the '●' character instead.  In reality only newly typed characters will become hidden. 

**Screenshots**
[Example](https://i.gyazo.com/e7f6284b4e5d3699d3eab92cf57bceff.mp4)
Button code:
     
             for event in pygame.event.get():
             
                 if event.type == pygame_gui.UI_BUTTON_PRESSED:                     
                 
                     if event.ui_element == self.visibility_button:
                     
                        self.visibility_button.disable()
                        self.visibility_button.hide()
                        self.hidden_button.enable()
                        self.hidden_button.show()
                        self.input_password.set_text_hidden(False)
                                                
                    if event.ui_element == self.hidden_button:
                    
                        self.hidden_button.disable()
                        self.hidden_button.hide()
                        self.visibility_button.enable()
                        self.visibility_button.show()
                        self.input_password.set_text_hidden(True)


**Platform and software:**
 - OS:  Windows
 - Pygame GUI version 0.6.8
 - Pygame version 2.1.2




Changed files:
pygame_gui/elements/ui_text_entry_line.py

diff --git a/pygame_gui/elements/ui_text_entry_line.py b/pygame_gui/elements/ui_text_entry_line.py
index e507dd9..7efa44c 100644
--- a/pygame_gui/elements/ui_text_entry_line.py
+++ b/pygame_gui/elements/ui_text_entry_line.py
@@ -200,7 +200,7 @@ class UITextEntryLine(UIElement):
                         raise ValueError('Selected font for UITextEntryLine does not contain '
                                          '●, * or . characters used for hidden text. Please choose'
                                          'a different font for this element')
-                display_text = self.hidden_text_char*len(self.text)
+            display_text = self.hidden_text_char*len(self.text)
 
         theming_parameters = {'normal_bg': self.background_colour,
                               'normal_text': self.text_colour,