fluxqueue-cli 0.1.0b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,178 @@
1
+ Copyright 2026 Giorgi Merebashvili
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: fluxqueue-cli
3
+ Version: 0.1.0b1
4
+ Summary: CLI for fluxqueue
5
+ Author-Email: Giorgi Merebashvili <mereba2627@gmail.com>
6
+ License-Expression: Apache
7
+ License-File: LICENSE
8
+ Requires-Python: <3.14,>=3.11
9
+ Requires-Dist: typer>=0.17.0
10
+ Requires-Dist: requests>=2.29.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: black; extra == "dev"
13
+ Requires-Dist: ruff; extra == "dev"
14
+ Requires-Dist: pdm; extra == "dev"
15
+ Description-Content-Type: text/markdown
16
+
17
+ ## FluxQueue CLI
18
+
19
+ A command-line tool for installing and running [FluxQueue](https://github.com/CCXLV/fluxqueue) workers.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install fluxqueue-cli
25
+ ```
26
+
27
+ ## Installing the Worker
28
+
29
+ Use the CLI to install the worker on your system:
30
+
31
+ ```bash
32
+ fluxqueue worker install
33
+ ```
34
+
35
+ ## Starting a Worker
36
+
37
+ To start a worker, provide the path to the module where your tasks are defined and exported:
38
+
39
+ ```bash
40
+ fluxqueue start --tasks-module-path src.tasks
41
+ ```
42
+
43
+ ## Documentation
44
+
45
+ For more information and documenation about the usage please visit [FluxQueue Documentation](https://fluxqueue.ccxlv.dev).
46
+
47
+ ## License
48
+
49
+ FluxQueue is licensed under the Apache-2.0 license. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,33 @@
1
+ ## FluxQueue CLI
2
+
3
+ A command-line tool for installing and running [FluxQueue](https://github.com/CCXLV/fluxqueue) workers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install fluxqueue-cli
9
+ ```
10
+
11
+ ## Installing the Worker
12
+
13
+ Use the CLI to install the worker on your system:
14
+
15
+ ```bash
16
+ fluxqueue worker install
17
+ ```
18
+
19
+ ## Starting a Worker
20
+
21
+ To start a worker, provide the path to the module where your tasks are defined and exported:
22
+
23
+ ```bash
24
+ fluxqueue start --tasks-module-path src.tasks
25
+ ```
26
+
27
+ ## Documentation
28
+
29
+ For more information and documenation about the usage please visit [FluxQueue Documentation](https://fluxqueue.ccxlv.dev).
30
+
31
+ ## License
32
+
33
+ FluxQueue is licensed under the Apache-2.0 license. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ requires = [
3
+ "pdm-backend",
4
+ ]
5
+ build-backend = "pdm.backend"
6
+
7
+ [project]
8
+ name = "fluxqueue-cli"
9
+ dynamic = []
10
+ description = "CLI for fluxqueue"
11
+ readme = "README.md"
12
+ requires-python = ">=3.11,<3.14"
13
+ license = "Apache"
14
+ license-files = [
15
+ "LICENSE",
16
+ ]
17
+ authors = [
18
+ { name = "Giorgi Merebashvili", email = "mereba2627@gmail.com" },
19
+ ]
20
+ dependencies = [
21
+ "typer>=0.17.0",
22
+ "requests>=2.29.0",
23
+ ]
24
+ version = "0.1.0b1"
25
+
26
+ [project.scripts]
27
+ fluxqueue = "fluxqueue_cli.cli:app"
28
+
29
+ [project.optional-dependencies]
30
+ dev = [
31
+ "black",
32
+ "ruff",
33
+ "pdm",
34
+ ]
35
+
36
+ [tool.pdm.version]
37
+ source = "file"
38
+ path = "src/fluxqueue_cli/__init__.py"
39
+
40
+ [tool.black]
41
+ line-length = 79
42
+ include = "\\.pyi?$"
43
+ preview = true
44
+
45
+ [tool.ruff.lint]
46
+ select = [
47
+ "E",
48
+ "W",
49
+ "F",
50
+ "I",
51
+ "C",
52
+ "B",
53
+ "UP",
54
+ "N",
55
+ "SIM",
56
+ "RUF",
57
+ ]
58
+ ignore = [
59
+ "E501",
60
+ "B008",
61
+ "C901",
62
+ "N806",
63
+ ]
64
+ exclude = [
65
+ ".git",
66
+ ".ruff_cache",
67
+ ".venv",
68
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0b1"
@@ -0,0 +1,125 @@
1
+ import re
2
+ from typing import Annotated
3
+
4
+ import typer
5
+
6
+ from fluxqueue_cli.exceptions import InvalidVersionError
7
+ from fluxqueue_cli.worker import (
8
+ download_and_install,
9
+ start_worker,
10
+ update_worker,
11
+ )
12
+
13
+ app = typer.Typer()
14
+ worker_app = typer.Typer()
15
+
16
+ app.add_typer(worker_app, name="worker", help="Worker related commands.")
17
+
18
+
19
+ @app.command()
20
+ def start(
21
+ *,
22
+ concurrency: Annotated[
23
+ int,
24
+ typer.Option(
25
+ "--concurrency",
26
+ "-c",
27
+ envvar="FLUXQUEUE_CONCURRENCY",
28
+ help="Number of tasks to run in parallel.",
29
+ ),
30
+ ] = 4,
31
+ redis_url: Annotated[
32
+ str,
33
+ typer.Option(
34
+ "--redis-url",
35
+ "-r",
36
+ envvar="FLUXQUEUE_REDIS_URL",
37
+ help="Redis connection URL for the worker.",
38
+ ),
39
+ ] = "redis://127.0.0.1:6379",
40
+ tasks_module_path: Annotated[
41
+ str,
42
+ typer.Option(
43
+ "--tasks-module-path",
44
+ "-t",
45
+ envvar="FLUXQUEUE_TASKS_MODULE_PATH",
46
+ help="Python module path where task functions are defined (e.g. src.tasks).",
47
+ ),
48
+ ],
49
+ queue: Annotated[
50
+ str,
51
+ typer.Option(
52
+ "--queue",
53
+ "-q",
54
+ envvar="FLUXQUEUE_QUEUE",
55
+ help="Queue name the worker reads jobs from.",
56
+ ),
57
+ ] = "default",
58
+ save_dead_tasks: Annotated[
59
+ bool,
60
+ typer.Option(
61
+ is_flag=True,
62
+ help="Keep failed tasks that reached the retry limit so you can inspect them later.",
63
+ ),
64
+ ] = False,
65
+ ):
66
+ """
67
+ Start a [bold]fluxqueue[/bold] worker.
68
+ """
69
+ start_worker(
70
+ concurrency=concurrency,
71
+ redis_url=redis_url,
72
+ tasks_module_path=tasks_module_path,
73
+ queue=queue,
74
+ save_dead_tasks=save_dead_tasks,
75
+ )
76
+
77
+
78
+ @worker_app.command(name="install")
79
+ def worker_install(
80
+ version: Annotated[
81
+ str | None,
82
+ typer.Option(
83
+ help="Version to install. If omitted, installs the latest."
84
+ ),
85
+ ] = None,
86
+ ):
87
+ """
88
+ Download and install [bold]fluxqueue-worker[/bold].
89
+ """
90
+ if version:
91
+ pattern = r"^\d+\.\d+\.\d+$"
92
+
93
+ if not re.match(pattern, version):
94
+ raise InvalidVersionError(
95
+ "Invalid version. Please use versions like: 0.1.0, 0.2.3"
96
+ )
97
+
98
+ download_and_install(version)
99
+
100
+
101
+ @worker_app.command(name="update")
102
+ def worker_update(
103
+ version: Annotated[
104
+ str | None,
105
+ typer.Option(
106
+ help="Version to update to. If omitted, updates to the latest."
107
+ ),
108
+ ] = None,
109
+ no_backup: Annotated[
110
+ bool,
111
+ typer.Option(
112
+ is_flag=True,
113
+ flag_value=False,
114
+ help="Skip keeping a backup of the old binary when updating.",
115
+ ),
116
+ ] = False,
117
+ ):
118
+ """
119
+ Update [bold]fluxqueue-worker[/bold].
120
+ """
121
+ update_worker(version=version, no_backup=no_backup)
122
+
123
+
124
+ if __name__ == "__main__":
125
+ app()
@@ -0,0 +1,18 @@
1
+ class ReleaseNotFoundError(Exception):
2
+ pass
3
+
4
+
5
+ class InvalidVersionError(Exception):
6
+ pass
7
+
8
+
9
+ class AlreadyInstalledError(Exception):
10
+ pass
11
+
12
+
13
+ class BinaryNotFoundError(Exception):
14
+ pass
15
+
16
+
17
+ class NotInstalledError(Exception):
18
+ pass
@@ -0,0 +1,215 @@
1
+ import os
2
+ import platform
3
+ import re
4
+ import shutil
5
+ import subprocess
6
+ import sys
7
+ import tarfile
8
+ import tempfile
9
+ from pathlib import Path
10
+
11
+ import requests
12
+
13
+ from fluxqueue_cli.exceptions import (
14
+ AlreadyInstalledError,
15
+ BinaryNotFoundError,
16
+ InvalidVersionError,
17
+ NotInstalledError,
18
+ ReleaseNotFoundError,
19
+ )
20
+
21
+ REPO = "CCXLV/fluxqueue"
22
+ BINARY_NAME = "fluxqueue-worker"
23
+ INSTALL_DIR = "/usr/local/bin" if platform.system() != "Windows" else "C:\\bin"
24
+
25
+ # TODO: Refactor the headers since the token won't be needed when launched to public
26
+
27
+
28
+ def start_worker(
29
+ *,
30
+ concurrency: int,
31
+ redis_url: str,
32
+ tasks_module_path: str,
33
+ queue: str,
34
+ save_dead_tasks=False,
35
+ ):
36
+ # fmt: off
37
+ arguments = [
38
+ "--concurrency", str(concurrency),
39
+ "--redis-url", redis_url,
40
+ "--tasks-module-path", tasks_module_path,
41
+ "--queue", queue,
42
+ ]
43
+ # fmt: on
44
+
45
+ if save_dead_tasks:
46
+ arguments.append("--save-dead-tasks")
47
+
48
+ subprocess.run(
49
+ ["fluxqueue-worker", *arguments],
50
+ stdin=sys.stdin,
51
+ stdout=sys.stdout,
52
+ stderr=sys.stderr,
53
+ )
54
+
55
+
56
+ def get_worker_version() -> str | None:
57
+ try:
58
+ result = subprocess.run(
59
+ ["fluxqueue-worker", "--version"],
60
+ check=True,
61
+ capture_output=True,
62
+ text=True,
63
+ )
64
+ return result.stdout.replace("fluxqueue-worker", "").strip()
65
+ except (FileNotFoundError, subprocess.CalledProcessError):
66
+ return None
67
+
68
+
69
+ def get_worker_release(version: str | None = None):
70
+ version_pattern = r"^worker-v(\d+\.\d+\.\d+)$"
71
+
72
+ headers = {
73
+ "Accept": "application/vnd.github.v3+json",
74
+ }
75
+ api_url = f"https://api.github.com/repos/{REPO}/releases"
76
+ response = requests.get(api_url, headers=headers)
77
+ response.raise_for_status()
78
+
79
+ worker_releases = []
80
+ for r in response.json():
81
+ match = re.match(version_pattern, r["tag_name"])
82
+ if match:
83
+ r["extracted_version"] = match.group(1)
84
+ worker_releases.append(r)
85
+
86
+ if not worker_releases:
87
+ raise ReleaseNotFoundError("No worker releases found.")
88
+
89
+ if version:
90
+ for r in worker_releases:
91
+ if r["extracted_version"] == version:
92
+ return r
93
+ available = [r["extracted_version"] for r in worker_releases]
94
+ raise InvalidVersionError(
95
+ f"Worker version {version} not found.\n"
96
+ f"Available versions: {', '.join(available)}"
97
+ )
98
+ return worker_releases[0]
99
+
100
+
101
+ def download_worker_binary(version: str | None = None):
102
+ release = get_worker_release(version)
103
+ version = release["extracted_version"]
104
+
105
+ py_version = f"{sys.version_info.major}.{sys.version_info.minor}"
106
+ system = platform.system().lower()
107
+
108
+ print(f"Detected: Python {py_version} on {system}")
109
+ print(f"Fetching latest worker: {version}")
110
+ asset_api_url = None
111
+ target_name: str | None = None
112
+ for asset in release["assets"]:
113
+ name = asset["name"]
114
+ if f"py{py_version}" in name and system in name:
115
+ asset_api_url = asset["url"]
116
+ target_name = str(name)
117
+ break
118
+
119
+ if not asset_api_url or not target_name:
120
+ raise BinaryNotFoundError(
121
+ f"No binary found for Python {py_version} on {system}."
122
+ )
123
+
124
+ print(f"Downloading {target_name} via API...")
125
+
126
+ headers = {
127
+ "Accept": "application/octet-stream",
128
+ }
129
+
130
+ try:
131
+ r = requests.get(asset_api_url, headers=headers, stream=True)
132
+ r.raise_for_status()
133
+ except:
134
+ delete_installed_files(target_name)
135
+ raise
136
+
137
+ with tempfile.NamedTemporaryFile(prefix=target_name, delete=False) as f:
138
+ temp_path = Path(f.name)
139
+ shutil.copyfileobj(r.raw, f)
140
+
141
+ return str(temp_path), target_name
142
+
143
+
144
+ def install_worker(
145
+ *, actual_file_name: str, temp_file_path: str, overwrite=False
146
+ ):
147
+ dest_path = Path(INSTALL_DIR) / BINARY_NAME
148
+ if dest_path.exists() and not overwrite:
149
+ raise FileExistsError(
150
+ f"fluxqueue-worker is already installed at {dest_path}"
151
+ )
152
+
153
+ # Linux
154
+ if actual_file_name.endswith(".tar.gz"):
155
+ with tarfile.open(temp_file_path, "r:gz") as tar:
156
+ try:
157
+ tar.extractall(path=".", filter="data")
158
+
159
+ os.chmod(BINARY_NAME, 0o755)
160
+
161
+ shutil.copy2(BINARY_NAME, dest_path)
162
+ delete_installed_files(temp_file_path)
163
+ except:
164
+ delete_installed_files(temp_file_path)
165
+ raise
166
+ # TODO: Implement Windows
167
+ else:
168
+ delete_installed_files(temp_file_path)
169
+ raise NotImplementedError(
170
+ "Only .tar.gz installation is implemented yet."
171
+ )
172
+
173
+ print(f"Successfully installed {BINARY_NAME} to {INSTALL_DIR}")
174
+
175
+
176
+ def download_and_install(version: str | None = None):
177
+ if shutil.which("fluxqueue-worker"):
178
+ raise AlreadyInstalledError(
179
+ "fluxqueue-worker is already installed, use `fluxqueue worker update` command to update it."
180
+ )
181
+
182
+ temp_path, target_name = download_worker_binary(version)
183
+ install_worker(actual_file_name=target_name, temp_file_path=temp_path)
184
+
185
+
186
+ def update_worker(*, version: str | None = None, no_backup: bool = False):
187
+ current_version = get_worker_version()
188
+
189
+ if not current_version:
190
+ raise NotInstalledError(
191
+ "fluxqueue-worker is not installed. Use `fluxqueue worker install` to install it."
192
+ )
193
+
194
+ print(f"Current Version: {current_version}")
195
+ if version:
196
+ print(f"Desired Version: {version}")
197
+
198
+ dest_path = os.path.join(INSTALL_DIR, BINARY_NAME)
199
+ if not no_backup:
200
+ new_name = os.path.join(
201
+ INSTALL_DIR, f"{BINARY_NAME}-{current_version}.backup"
202
+ )
203
+ os.rename(dest_path, new_name)
204
+
205
+ temp_path, target_name = download_worker_binary(version)
206
+ install_worker(
207
+ actual_file_name=target_name,
208
+ temp_file_path=temp_path,
209
+ overwrite=no_backup,
210
+ )
211
+
212
+
213
+ def delete_installed_files(temp_path: str):
214
+ os.remove(BINARY_NAME)
215
+ os.remove(temp_path)