yipenghe: Does this affect #2040 ?
candicegjing: > Does this affect #2040 ?

This change will cover both `--request-queue tag=foo` and `--request-queue foo`. So I think it won't affect changes in #2040. If not, please let me know
candicegjing: @bkgoksel This is ready for another review~ Let me know if I need to change anything.
diff --git a/codalab/server/bundle_manager.py b/codalab/server/bundle_manager.py
index 1bc20140..bc81a861 100644
--- a/codalab/server/bundle_manager.py
+++ b/codalab/server/bundle_manager.py
@@ -676,12 +676,12 @@ class BundleManager(object):
     def _get_matched_workers(request_queue, workers):
         """
         Get all of the workers that match with the name of the requested worker
-        :param request_queue: a tag that can be used to match workers
+        :param request_queue: a tag with the format "tag=worker_X" or "worker_X" that can be used to match workers
         :param workers: a list of workers
         :return: a list of matched workers
         """
-        tag_match = re.match('tag=(.+)', request_queue)
-        if tag_match != None:
+        tag_match = re.match('(?:tag=)?(.+)', request_queue)
+        if tag_match is not None:
             return [worker for worker in workers if worker['tag'] == tag_match.group(1)]
         return []
 

Supporting request-queue for both formats: tag=<X> and X
When a bundle is requested to run on a specific worker, we currently use `--request-queue tag=<worker_X>` to indicate the worker that the bundle should run on. This ticket is to add support for another format: `--request-queue worker_X`.
diff --git a/tests/server/bundle_manager_test.py b/tests/server/bundle_manager_test.py
index 76a84c1b..4b894c3a 100644
--- a/tests/server/bundle_manager_test.py
+++ b/tests/server/bundle_manager_test.py
@@ -84,7 +84,7 @@ class BundleManagerTest(unittest.TestCase):
                 'cpus': 6,
                 'gpus': 0,
                 'memory_bytes': 2 * 1000,
-                'tag': None,
+                'tag': 'worker_X',
                 'run_uuids': [],
                 'dependencies': [],
                 'shared_file_system': False,
@@ -111,3 +111,40 @@ class BundleManagerTest(unittest.TestCase):
         )
         self.assertEqual(len(sorted_workers_list), 5)
         self.assertEqual(sorted_workers_list[0]['worker_id'], 3)
+
+    def test__get_matched_workers_with_tag(self):
+        self.bundle.metadata.request_queue = "tag=worker_X"
+        matched_workers = BundleManager._get_matched_workers(
+            self.bundle.metadata.request_queue, self.workers_list
+        )
+        self.assertEqual(len(matched_workers), 1)
+        self.assertEqual(matched_workers[0]['worker_id'], 4)
+
+    def test__get_matched_workers_with_bad_formatted_tag(self):
+        self.bundle.metadata.request_queue = "tag="
+        matched_workers = BundleManager._get_matched_workers(
+            self.bundle.metadata.request_queue, self.workers_list
+        )
+        self.assertEqual(len(matched_workers), 0)
+
+    def test__get_matched_workers_without_tag_prefix(self):
+        self.bundle.metadata.request_queue = "worker_X"
+        matched_workers = BundleManager._get_matched_workers(
+            self.bundle.metadata.request_queue, self.workers_list
+        )
+        self.assertEqual(len(matched_workers), 1)
+        self.assertEqual(matched_workers[0]['worker_id'], 4)
+
+    def test__get_matched_workers_not_exist_tag(self):
+        self.bundle.metadata.request_queue = "worker_Y"
+        matched_workers = BundleManager._get_matched_workers(
+            self.bundle.metadata.request_queue, self.workers_list
+        )
+        self.assertEqual(len(matched_workers), 0)
+
+    def test__get_matched_workers_empty_tag(self):
+        self.bundle.metadata.request_queue = ""
+        matched_workers = BundleManager._get_matched_workers(
+            self.bundle.metadata.request_queue, self.workers_list
+        )
+        self.assertEqual(len(matched_workers), 0)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest mock
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
argcomplete==1.9.4
argh==0.31.3
bottle==0.12.9
certifi==2025.1.31
charset-normalizer==3.4.1
-e git+https://github.com/codalab/codalab-worksheets.git@a7a62e5848083f2f9c948bcd7969d8a8fba535f8#egg=codalab
diffimg==0.2.3
docker==3.7.0
docker-pycreds==0.4.0
exceptiongroup==1.2.2
fusepy==2.0.4
idna==3.10
iniconfig==2.1.0
marshmallow==2.15.1
marshmallow-jsonapi==0.15.1
mock==5.2.0
packaging==24.2
pathtools==0.1.2
pillow==11.1.0
pluggy==1.5.0
psutil==5.4.6
pytest==8.3.5
python-dateutil==2.9.0.post0
PyYAML==5.1
requests==2.32.3
selenium==3.141.0
six==1.11.0
SQLAlchemy==1.3.0
tomli==2.2.1
urllib3==2.3.0
watchdog==0.8.3
websocket-client==1.8.0

name: codalab-worksheets
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - argcomplete==1.9.4
      - argh==0.31.3
      - bottle==0.12.9
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - codalab==0.5.9
      - diffimg==0.2.3
      - docker==3.7.0
      - docker-pycreds==0.4.0
      - exceptiongroup==1.2.2
      - fusepy==2.0.4
      - idna==3.10
      - iniconfig==2.1.0
      - marshmallow==2.15.1
      - marshmallow-jsonapi==0.15.1
      - mock==5.2.0
      - packaging==24.2
      - pathtools==0.1.2
      - pillow==11.1.0
      - pluggy==1.5.0
      - psutil==5.4.6
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pyyaml==5.1
      - requests==2.32.3
      - selenium==3.141.0
      - six==1.11.0
      - sqlalchemy==1.3.0
      - tomli==2.2.1
      - urllib3==2.3.0
      - watchdog==0.8.3
      - websocket-client==1.8.0
prefix: /opt/conda/envs/codalab-worksheets

tests/server/bundle_manager_test.py::BundleManagerTest::test__get_matched_workers_without_tag_prefix
tests/server/bundle_manager_test.py::BundleManagerTest::test__filter_and_sort_workers_cpus tests/server/bundle_manager_test.py::BundleManagerTest::test__filter_and_sort_workers_gpus tests/server/bundle_manager_test.py::BundleManagerTest::test__get_matched_workers_empty_tag tests/server/bundle_manager_test.py::BundleManagerTest::test__get_matched_workers_not_exist_tag tests/server/bundle_manager_test.py::BundleManagerTest::test__get_matched_workers_with_bad_formatted_tag tests/server/bundle_manager_test.py::BundleManagerTest::test__get_matched_workers_with_tag
codalab/server/bundle_manager.py
codalab/server/bundle_manager.py