Repository: codalab/codalab-worksheets

Issue:
cl run --interactive doesn't work with cl upload --link
To reproduce:

```
cl upload /u/scr/nlp --link
cl run :nlp '' --interactive
```
It drops me into a docker container with `nlp` mounted, but it's empty.

But if I use non-link bundles, then the contents show up just fine.

Discussion:

Patch:
diff --git a/codalab/lib/interactive_session.py b/codalab/lib/interactive_session.py
index 9ee96254..73b252be 100644
--- a/codalab/lib/interactive_session.py
+++ b/codalab/lib/interactive_session.py
@@ -31,7 +31,7 @@ class InteractiveSession:
         9. Stop and remove the interactive session container.
     """
 
-    _BASH_HISTORY_CONTAINER_PATH = "/usr/sbin/.bash_history"
+    _BASH_HISTORY_CONTAINER_PATH = "/root/.bash_history"
     _CHOOSE_COMMAND_INSTRUCTIONS = (
         "\n\n#\n"
         "# Choose the commands to use for cl run:\n"
@@ -143,14 +143,14 @@ class InteractiveSession:
                 volumes[get_docker_path(key)] = dependency_local_path
 
         name = self._get_container_name()
-        # Start a container as a non-root user. Root (id = 0) is the default user within a container.
-        # When passing a numeric ID, the user does not have to exist in the container.
+        # Start a container as a root user. Root (id = 0) is the default user within a container.
         command = [
             'docker run',
             '-it',
             f'--name {name}',
             f'-w {os.path.sep}{self._session_uuid}',
-            '-u 1',
+            # TODO: figure out a way to run as a non-root user and be able to save the bash_history on any machine
+            # '-u 1',
         ]
         command.extend(
             [
diff --git a/codalab/rest/bundles.py b/codalab/rest/bundles.py
index 2f001e26..711463a8 100644
--- a/codalab/rest/bundles.py
+++ b/codalab/rest/bundles.py
@@ -403,7 +403,7 @@ def _fetch_locations():
     bundle_uuids = query_get_list('uuids')
     bundle_link_urls = local.model.get_bundle_metadata(bundle_uuids, "link_url")
     uuids_to_locations = {
-        uuid: bundle_link_urls.get("uuid") or local.bundle_store.get_bundle_location(uuid)
+        uuid: bundle_link_urls.get(uuid) or local.bundle_store.get_bundle_location(uuid)
         for uuid in bundle_uuids
     }
     return dict(data=uuids_to_locations)


Test patch:
diff --git a/tests/unit/lib/interactive_session_test.py b/tests/unit/lib/interactive_session_test.py
index 584e7873..f5c5ab6d 100644
--- a/tests/unit/lib/interactive_session_test.py
+++ b/tests/unit/lib/interactive_session_test.py
@@ -14,9 +14,9 @@ class InteractiveSessionTest(unittest.TestCase):
         )
         session._host_bash_history_path = ".bash_history"
         expected_regex = (
-            'docker run -it --name interactive-session-0x[a-z0-9]{32} -w \/0x[a-z0-9]{32} -u 1 -v '
+            'docker run -it --name interactive-session-0x[a-z0-9]{32} -w \/0x[a-z0-9]{32} -v '
             '[\s\S]{0,100}local\/path1:\/0x[a-z0-9]{32}\/key:ro -v [\s\S]{0,100}local\/path2:\/0x[a-z0-9]{32}\/key2:ro '
-            '-v \.bash_history:\/usr\/sbin\/\.bash_history:rw some-docker-image bash'
+            '-v \.bash_history:\/root\/.bash_history:rw some-docker-image bash'
         )
         self.assertTrue(re.match(expected_regex, session.get_docker_run_command()))
 
@@ -31,9 +31,9 @@ class InteractiveSessionTest(unittest.TestCase):
         )
         session._host_bash_history_path = ".bash_history"
         expected_regex = (
-            'docker run -it --name interactive-session-0x[a-z0-9]{32} -w \/0x[a-z0-9]{32} -u 1 -v '
+            'docker run -it --name interactive-session-0x[a-z0-9]{32} -w \/0x[a-z0-9]{32} -v '
             '[\s\S]{0,100}local\/path1/sub/path1:\/0x[a-z0-9]{32}\/key:ro -v [\s\S]{0,100}local\/path2/sub/path2'
-            ':\/0x[a-z0-9]{32}\/key2:ro -v \.bash_history:\/usr\/sbin\/\.bash_history:rw some-docker-image bash'
+            ':\/0x[a-z0-9]{32}\/key2:ro -v \.bash_history:\/root\/.bash_history:rw some-docker-image bash'
         )
         self.assertTrue(re.match(expected_regex, session.get_docker_run_command()))