machineconfig 2.2__py3-none-any.whl → 2.4__py3-none-any.whl
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.
Potentially problematic release.
This version of machineconfig might be problematic. Click here for more details.
- machineconfig/__init__.py +30 -0
- machineconfig/cluster/sessions_managers/enhanced_command_runner.py +0 -2
- machineconfig/cluster/sessions_managers/layout_types.py +29 -0
- machineconfig/cluster/sessions_managers/wt_local.py +68 -62
- machineconfig/cluster/sessions_managers/wt_local_manager.py +51 -22
- machineconfig/cluster/sessions_managers/wt_remote.py +30 -108
- machineconfig/cluster/sessions_managers/wt_remote_manager.py +14 -11
- machineconfig/cluster/sessions_managers/wt_utils/layout_generator.py +33 -37
- machineconfig/cluster/sessions_managers/wt_utils/process_monitor.py +22 -17
- machineconfig/cluster/sessions_managers/wt_utils/session_manager.py +59 -10
- machineconfig/cluster/sessions_managers/wt_utils/status_reporter.py +16 -14
- machineconfig/cluster/sessions_managers/zellij_local.py +75 -57
- machineconfig/cluster/sessions_managers/zellij_local_manager.py +51 -23
- machineconfig/cluster/sessions_managers/zellij_remote.py +47 -27
- machineconfig/cluster/sessions_managers/zellij_remote_manager.py +13 -12
- machineconfig/cluster/sessions_managers/zellij_utils/example_usage.py +14 -10
- machineconfig/cluster/sessions_managers/zellij_utils/layout_generator.py +31 -15
- machineconfig/cluster/sessions_managers/zellij_utils/process_monitor.py +47 -21
- machineconfig/cluster/sessions_managers/zellij_utils/session_manager.py +1 -1
- machineconfig/cluster/sessions_managers/zellij_utils/status_reporter.py +8 -7
- machineconfig/cluster/templates/utils.py +1 -1
- machineconfig/profile/create.py +4 -0
- machineconfig/scripts/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/linux/checkout_versions +1 -7
- machineconfig/scripts/linux/choose_wezterm_theme +1 -7
- machineconfig/scripts/linux/cloud_copy +1 -8
- machineconfig/scripts/linux/cloud_manager +1 -7
- machineconfig/scripts/linux/cloud_mount +1 -23
- machineconfig/scripts/linux/cloud_repo_sync +1 -21
- machineconfig/scripts/linux/cloud_sync +1 -23
- machineconfig/scripts/linux/croshell +1 -23
- machineconfig/scripts/linux/devops +0 -21
- machineconfig/scripts/linux/fire +1 -27
- machineconfig/scripts/linux/fire_agents +1 -26
- machineconfig/scripts/linux/gh_models +1 -10
- machineconfig/scripts/linux/kill_process +1 -9
- machineconfig/scripts/linux/mcinit +1 -26
- machineconfig/scripts/linux/mount_nfs +1 -13
- machineconfig/scripts/linux/repos +1 -23
- machineconfig/scripts/linux/scheduler +1 -7
- machineconfig/scripts/linux/start_slidev +1 -22
- machineconfig/scripts/linux/start_terminals +1 -9
- machineconfig/scripts/linux/url2md +1 -9
- machineconfig/scripts/python/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/croshell.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/devops_update_repos.cpython-313.pyc +0 -0
- machineconfig/scripts/python/cloud_mount.py +4 -2
- machineconfig/scripts/python/cloud_repo_sync.py +5 -2
- machineconfig/scripts/python/cloud_sync.py +4 -2
- machineconfig/scripts/python/croshell.py +5 -3
- machineconfig/scripts/python/devops.py +3 -2
- machineconfig/scripts/python/devops_devapps_install.py +1 -0
- machineconfig/scripts/python/fire_agents.py +6 -6
- machineconfig/scripts/python/fire_jobs.py +26 -72
- machineconfig/scripts/python/fire_jobs_args_helper.py +84 -0
- machineconfig/scripts/python/fire_jobs_layout_helper.py +66 -0
- machineconfig/scripts/python/helpers/helpers4.py +0 -1
- machineconfig/scripts/python/mount_nfs.py +12 -8
- machineconfig/scripts/python/mount_nw_drive.py +6 -6
- machineconfig/scripts/python/mount_ssh.py +4 -2
- machineconfig/scripts/python/start_slidev.py +4 -2
- machineconfig/scripts/python/start_terminals.py +4 -2
- machineconfig/scripts/python/wifi_conn.py +0 -1
- machineconfig/settings/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/settings/shells/ipy/profiles/default/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/settings/shells/ipy/profiles/default/startup/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/utils/code.py +5 -6
- machineconfig/utils/installer_utils/installer_abc.py +0 -1
- machineconfig/utils/options.py +7 -7
- machineconfig/utils/path.py +12 -12
- machineconfig/utils/path_reduced.py +6 -1
- machineconfig/utils/source_of_truth.py +2 -2
- machineconfig/utils/ssh.py +11 -1
- machineconfig/utils/upgrade_packages.py +12 -12
- {machineconfig-2.2.dist-info → machineconfig-2.4.dist-info}/METADATA +1 -1
- {machineconfig-2.2.dist-info → machineconfig-2.4.dist-info}/RECORD +90 -93
- machineconfig-2.4.dist-info/entry_points.txt +2 -0
- machineconfig/cluster/sessions_managers/archive/create_zellij_template.py +0 -60
- machineconfig/cluster/sessions_managers/archive/session_managers.py +0 -183
- machineconfig/cluster/sessions_managers/demo_rich_zellij.py +0 -0
- machineconfig/jobs/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/python_generic_installers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/jobs/python_linux_installers/__pycache__/__init__.cpython-313.pyc +0 -0
- machineconfig/scripts/linux/archive/tmate_conn +0 -12
- machineconfig/scripts/linux/archive/tmate_start +0 -12
- machineconfig/scripts/linux/archive/transfer_wsl_win +0 -5
- machineconfig/scripts/python/__pycache__/devops_devapps_install.cpython-313.pyc +0 -0
- machineconfig/scripts/python/__pycache__/fire_agents.cpython-313.pyc +0 -0
- /machineconfig/cluster/{cloud_manager.py → remote/cloud_manager.py} +0 -0
- /machineconfig/cluster/{data_transfer.py → remote/data_transfer.py} +0 -0
- /machineconfig/cluster/{distribute.py → remote/distribute.py} +0 -0
- /machineconfig/cluster/{file_manager.py → remote/file_manager.py} +0 -0
- /machineconfig/cluster/{job_params.py → remote/job_params.py} +0 -0
- /machineconfig/cluster/{loader_runner.py → remote/loader_runner.py} +0 -0
- /machineconfig/cluster/{remote_machine.py → remote/remote_machine.py} +0 -0
- /machineconfig/cluster/{script_execution.py → remote/script_execution.py} +0 -0
- /machineconfig/cluster/{script_notify_upon_completion.py → remote/script_notify_upon_completion.py} +0 -0
- /machineconfig/{cluster/sessions_managers/archive/__init__.py → scripts/python/fire_jobs_streamlit_helper.py} +0 -0
- {machineconfig-2.2.dist-info → machineconfig-2.4.dist-info}/WHEEL +0 -0
- {machineconfig-2.2.dist-info → machineconfig-2.4.dist-info}/top_level.txt +0 -0
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
|
|
2
1
|
#!/usr/bin/env bash
|
|
3
|
-
|
|
4
|
-
source ~/code/machineconfig/.venv/bin/activate
|
|
5
|
-
|
|
6
|
-
python -m machineconfig.scripts.python.gh_models "$@"
|
|
7
|
-
|
|
8
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
9
|
-
deactivate || true
|
|
10
|
-
|
|
11
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.scripts.python.gh_models "$@"
|
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source ~/code/machineconfig/.venv/bin/activate
|
|
4
|
-
|
|
5
|
-
python -c "from machineconfig.utils.procs import ProcessManager; ProcessManager().choose_and_kill()"
|
|
6
|
-
|
|
7
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
8
|
-
deactivate || true
|
|
9
|
-
|
|
10
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -c "from machineconfig.utils.procs import ProcessManager; ProcessManager().choose_and_kill()"
|
|
@@ -1,27 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
. $HOME/code/machineconfig/.venv/bin/activate
|
|
4
|
-
|
|
5
|
-
# Generate random string of length 5
|
|
6
|
-
random_str=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n 1)
|
|
7
|
-
export op_script=$HOME/tmp_results/shells/$random_str/python_return_command.sh
|
|
8
|
-
# op_script=$HOME/tmp_results/shells/$random_str/python_return_command.sh
|
|
9
|
-
|
|
10
|
-
if [ -f "$op_script" ]; then
|
|
11
|
-
rm $op_script
|
|
12
|
-
fi
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
python -m machineconfig.scripts.python.ai.mcinit "$@"
|
|
16
|
-
|
|
17
|
-
if [ -f "$op_script" ]; then
|
|
18
|
-
echo "Running $op_script"
|
|
19
|
-
chmod +x $op_script
|
|
20
|
-
set -- # clear all positional parameters
|
|
21
|
-
source $op_script # sourcing the script means the args passed to the this script are passed to the sourced script which cofuses the sources script as it contains activate_ve and it doesn't understand first.sh arguments.
|
|
22
|
-
fi
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
26
|
-
deactivate || true
|
|
27
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.scripts.python.ai.mcinit "$@"
|
|
@@ -5,19 +5,7 @@
|
|
|
5
5
|
# mkdir ~/data/local
|
|
6
6
|
# sudo mount -o nolock,noatime,nodiratime,proto=tcp,timeo=600,retrans=2,noac alex-p51s-5:/home/alex/data/local ./data/local
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
op_script=$HOME/tmp_results/shells/python_return_command.sh
|
|
10
|
-
if [ -f "$op_script" ]; then
|
|
11
|
-
rm $op_script
|
|
12
|
-
fi
|
|
13
|
-
. activate_ve
|
|
14
|
-
python -m machineconfig.scripts.python.mount_nfs
|
|
15
|
-
#source $HOME/tmp_results/shells/python_return_command.sh
|
|
16
|
-
if [ -f "$op_script" ]; then
|
|
17
|
-
chmod +x $op_script
|
|
18
|
-
source $op_script
|
|
19
|
-
fi
|
|
20
|
-
|
|
8
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.scripts.python.mount_nfs
|
|
21
9
|
# Check if remote server is reachable and share folder exists
|
|
22
10
|
if ! ping -c 1 "$remote_server" &> /dev/null; then
|
|
23
11
|
echo "💥 Error: Remote server $remote_server is not reachable."
|
|
@@ -1,24 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# check below if VIRTUAL_ENV is set
|
|
4
|
-
# if [ -z "$VIRTUAL_ENV" ]; then
|
|
5
|
-
source ~/code/machineconfig/.venv/bin/activate
|
|
6
|
-
# fi
|
|
7
|
-
|
|
8
|
-
op_script=$HOME/tmp_results/shells/python_return_command.sh
|
|
9
|
-
if [ -f "$op_script" ]; then
|
|
10
|
-
rm $op_script
|
|
11
|
-
fi
|
|
12
|
-
|
|
13
|
-
python -m machineconfig.scripts.python.repos "$@"
|
|
14
|
-
|
|
15
|
-
if [ -f "$op_script" ]; then
|
|
16
|
-
chmod +x $op_script
|
|
17
|
-
source $op_script
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# check below if VIRTUAL_ENV enviroment variable exist, then deactivate it, otherwise skip
|
|
22
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
23
|
-
deactivate
|
|
24
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.scripts.python.repos "$@"
|
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source ~/code/machineconfig/.venv/bin/activate
|
|
4
|
-
python -m machineconfig.scripts.python.scheduler "$@"
|
|
5
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
6
|
-
deactivate || true
|
|
7
|
-
|
|
8
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.scripts.python.scheduler "$@"
|
|
@@ -1,23 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source ~/code/machineconfig/.venv/bin/activate
|
|
4
|
-
|
|
5
|
-
op_script=$HOME/tmp_results/shells/python_return_command.sh
|
|
6
|
-
if [ -f "$op_script" ]; then
|
|
7
|
-
rm $op_script
|
|
8
|
-
fi
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
python -m machineconfig.scripts.python.start_slidev "$@"
|
|
12
|
-
|
|
13
|
-
if [ -f "$op_script" ]; then
|
|
14
|
-
chmod +x $op_script
|
|
15
|
-
set -- # clear all positional parameters
|
|
16
|
-
source $op_script # sourcing the script means the args passed to the this script are passed to the sourced script which cofuses the sources script as it contains activate_ve and it doesn't understand first.sh arguments.
|
|
17
|
-
fi
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
21
|
-
deactivate || true
|
|
22
|
-
|
|
23
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.scripts.python.start_slidev "$@"
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
python -m machineconfig.jobs.python.create_zellij_template
|
|
6
|
-
|
|
3
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.jobs.python.create_zellij_template
|
|
7
4
|
zellij --layout $HOME/tmp_results/tmp_files/templates/zellij_template.kdl
|
|
8
|
-
|
|
9
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
10
|
-
deactivate || true
|
|
11
|
-
|
|
12
|
-
fi
|
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source ~/code/machineconfig/.venv/bin/activate
|
|
4
|
-
|
|
5
|
-
python -m machineconfig.utils.ai.url2md "$@"
|
|
6
|
-
|
|
7
|
-
if [ -n "$VIRTUAL_ENV" ]; then
|
|
8
|
-
deactivate || true
|
|
9
|
-
|
|
10
|
-
fi
|
|
2
|
+
uv run --no-dev --project $HOME/code/machineconfig python -m machineconfig.utils.ai.url2md "$@"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Cloud mount script"""
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
4
|
from machineconfig.utils.options import choose_one_option
|
|
5
5
|
from machineconfig.utils.utils2 import read_ini
|
|
6
6
|
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
@@ -144,7 +144,9 @@ zellij action move-focus up
|
|
|
144
144
|
else:
|
|
145
145
|
raise ValueError("unsupported platform")
|
|
146
146
|
# print(f"running command: \n{txt}")
|
|
147
|
-
PROGRAM_PATH.write_text(txt, encoding="utf-8")
|
|
147
|
+
# PROGRAM_PATH.write_text(txt, encoding="utf-8")
|
|
148
|
+
import subprocess
|
|
149
|
+
subprocess.run(txt, shell=True, check=True)
|
|
148
150
|
# draw success box dynamically
|
|
149
151
|
title1 = "✅ Cloud mount command prepared successfully"
|
|
150
152
|
title2 = "🔄 Running mount process..."
|
|
@@ -7,7 +7,7 @@ from machineconfig.utils.terminal import Terminal
|
|
|
7
7
|
from machineconfig.utils.utils2 import randstr, read_ini
|
|
8
8
|
|
|
9
9
|
from machineconfig.scripts.python.helpers.repo_sync_helpers import fetch_dotfiles
|
|
10
|
-
from machineconfig.utils.source_of_truth import CONFIG_PATH, DEFAULTS_PATH
|
|
10
|
+
from machineconfig.utils.source_of_truth import CONFIG_PATH, DEFAULTS_PATH
|
|
11
11
|
from machineconfig.utils.options import choose_one_option
|
|
12
12
|
from machineconfig.utils.code import get_shell_file_executing_python_script, write_shell_script_to_file
|
|
13
13
|
import platform
|
|
@@ -161,7 +161,10 @@ git commit -am "finished merging"
|
|
|
161
161
|
program_content = program_4
|
|
162
162
|
case _:
|
|
163
163
|
raise ValueError(f"Unknown action: {action}")
|
|
164
|
-
PROGRAM_PATH.write_text(program_content, encoding="utf-8")
|
|
164
|
+
# PROGRAM_PATH.write_text(program_content, encoding="utf-8")
|
|
165
|
+
import subprocess
|
|
166
|
+
subprocess.run(program_content, shell=True, check=True)
|
|
167
|
+
|
|
165
168
|
return program_content
|
|
166
169
|
|
|
167
170
|
|
|
@@ -5,7 +5,7 @@ TODO: use typer or typed-argument-parser to parse args
|
|
|
5
5
|
from machineconfig.scripts.python.helpers.helpers2 import parse_cloud_source_target
|
|
6
6
|
from machineconfig.scripts.python.helpers.cloud_helpers import Args
|
|
7
7
|
from machineconfig.scripts.python.cloud_mount import get_mprocs_mount_txt
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
import argparse
|
|
10
10
|
from rich.console import Console
|
|
11
11
|
from rich.panel import Panel
|
|
@@ -75,7 +75,9 @@ def args_parser():
|
|
|
75
75
|
cmd_line = f"{rclone_cmd[:65]}..."
|
|
76
76
|
console.print(Panel(f"{title}\n{cmd_line}", title="[bold blue]Command[/bold blue]", expand=False))
|
|
77
77
|
|
|
78
|
-
PROGRAM_PATH.write_text(txt, encoding="utf-8")
|
|
78
|
+
# PROGRAM_PATH.write_text(txt, encoding="utf-8")
|
|
79
|
+
import subprocess
|
|
80
|
+
subprocess.run(txt, shell=True, check=True)
|
|
79
81
|
|
|
80
82
|
|
|
81
83
|
if __name__ == "__main__":
|
|
@@ -7,7 +7,7 @@ croshell
|
|
|
7
7
|
import argparse
|
|
8
8
|
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
9
9
|
from machineconfig.utils.utils2 import randstr
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
from machineconfig.utils.options import display_options
|
|
12
12
|
from machineconfig.utils.ve import get_ve_activate_line
|
|
13
13
|
from typing import Optional
|
|
@@ -204,11 +204,13 @@ print(f"🐊 Crocodile Shell | Running @ {Path.cwd()}")
|
|
|
204
204
|
title = "🚀 LAUNCHING SCRIPT"
|
|
205
205
|
text1 = f"📄 Script: {pyfile}"
|
|
206
206
|
text2 = f"🔥 Command: {fire_line}"
|
|
207
|
-
launch_message = f"{title}
|
|
207
|
+
launch_message = f"{title} \n{text1}\n{text2}"
|
|
208
208
|
console.print(Panel(Text(launch_message, justify="left"), expand=False, border_style="blue"))
|
|
209
209
|
|
|
210
|
-
PROGRAM_PATH.write_text(data=final_program, encoding="utf-8")
|
|
210
|
+
# PROGRAM_PATH.write_text(data=final_program, encoding="utf-8")
|
|
211
211
|
# (PROGRAM_PATH + ".py").write_text(str(pyfile), encoding='utf-8')
|
|
212
|
+
import subprocess
|
|
213
|
+
subprocess.run(final_program, shell=True, check=True)
|
|
212
214
|
|
|
213
215
|
# if platform.system() == "Windows":
|
|
214
216
|
# return subprocess.run([f"powershell", "-Command", res], shell=True, capture_output=False, text=True, check=True)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""devops with emojis"""
|
|
2
2
|
|
|
3
3
|
from machineconfig.utils.options import display_options
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
from machineconfig.utils.code import write_shell_script_to_default_program_path
|
|
6
6
|
from platform import system
|
|
7
7
|
from enum import Enum
|
|
@@ -74,7 +74,8 @@ def display_task_success(success: str) -> None:
|
|
|
74
74
|
|
|
75
75
|
def main(which: Optional[str] = None):
|
|
76
76
|
from machineconfig.utils.path_reduced import PathExtended
|
|
77
|
-
|
|
77
|
+
|
|
78
|
+
# PathExtended(PROGRAM_PATH).delete(sure=True, verbose=False)
|
|
78
79
|
console.print(Panel("🚀 Initializing DevOps operation...", width=BOX_WIDTH, border_style="blue"))
|
|
79
80
|
|
|
80
81
|
options = [op.value for op in Options]
|
|
@@ -39,6 +39,7 @@ def main(which: Optional[WHICH_CAT | str] = None):
|
|
|
39
39
|
# interactive installation
|
|
40
40
|
installers = [Installer.from_dict(d=vd, name=name) for __kat, vds in get_all_dicts(system=system()).items() for name, vd in vds.items()]
|
|
41
41
|
options = [x.get_description() for x in tqdm(installers, desc="✅ Checking installed programs")] + list(get_args(WHICH_CAT))
|
|
42
|
+
# print("s"*1000)
|
|
42
43
|
program_names = choose_multiple_options(msg="", options=options, header="🚀 CHOOSE DEV APP", default="AllEssentials")
|
|
43
44
|
|
|
44
45
|
total_program = ""
|
|
@@ -15,6 +15,7 @@ from math import ceil
|
|
|
15
15
|
from typing import Literal, TypeAlias, get_args, Iterable
|
|
16
16
|
|
|
17
17
|
from machineconfig.cluster.sessions_managers.zellij_local_manager import ZellijLocalManager
|
|
18
|
+
from machineconfig.cluster.sessions_managers.layout_types import TabConfig, LayoutConfig
|
|
18
19
|
from machineconfig.utils.utils2 import randstr
|
|
19
20
|
import random
|
|
20
21
|
# import time
|
|
@@ -23,7 +24,6 @@ AGENTS: TypeAlias = Literal[
|
|
|
23
24
|
"cursor-agent", "gemini", "crush", "q", "onlyPrepPromptFiles"
|
|
24
25
|
# warp terminal
|
|
25
26
|
]
|
|
26
|
-
TabConfig = dict[str, tuple[str, str]] # tab name -> (cwd, command)
|
|
27
27
|
DEFAULT_AGENT_CAP = 6
|
|
28
28
|
|
|
29
29
|
|
|
@@ -93,7 +93,7 @@ def _confirm(message: str, default_no: bool = True) -> bool:
|
|
|
93
93
|
return False
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
def launch_agents(repo_root: Path, prompts: list[str], agent: AGENTS, *, max_agents: int = DEFAULT_AGENT_CAP) -> TabConfig:
|
|
96
|
+
def launch_agents(repo_root: Path, prompts: list[str], agent: AGENTS, *, max_agents: int = DEFAULT_AGENT_CAP) -> list[TabConfig]:
|
|
97
97
|
"""Create tab configuration for a set of agent prompts.
|
|
98
98
|
|
|
99
99
|
If number of prompts exceeds max_agents, ask user for confirmation.
|
|
@@ -106,9 +106,9 @@ def launch_agents(repo_root: Path, prompts: list[str], agent: AGENTS, *, max_age
|
|
|
106
106
|
proceed = _confirm(message=(f"You are about to launch {len(prompts)} agents which exceeds the cap ({max_agents}). Proceed?"))
|
|
107
107
|
if not proceed:
|
|
108
108
|
print("Aborting per user choice.")
|
|
109
|
-
return
|
|
109
|
+
return []
|
|
110
110
|
|
|
111
|
-
tab_config: TabConfig =
|
|
111
|
+
tab_config: list[TabConfig] = []
|
|
112
112
|
tmp_dir = repo_root / ".ai" / f"tmp_prompts/{randstr()}"
|
|
113
113
|
tmp_dir.mkdir(parents=True, exist_ok=True)
|
|
114
114
|
|
|
@@ -173,7 +173,7 @@ echo "---------END OF AGENT OUTPUT---------"
|
|
|
173
173
|
"""
|
|
174
174
|
cmd_path.write_text(cmd_prefix + cmd + cmd_postfix, encoding="utf-8")
|
|
175
175
|
fire_cmd = f"bash {shlex.quote(str(cmd_path))}"
|
|
176
|
-
tab_config
|
|
176
|
+
tab_config.append(TabConfig(tabName=f"Agent{idx}", startDir=str(repo_root), command=fire_cmd))
|
|
177
177
|
|
|
178
178
|
print(f"Launching a template with #{len(tab_config)} agents")
|
|
179
179
|
return tab_config
|
|
@@ -228,7 +228,7 @@ def main(): # noqa: C901 - (complexity acceptable for CLI glue)
|
|
|
228
228
|
from machineconfig.utils.utils2 import randstr
|
|
229
229
|
|
|
230
230
|
random_name = randstr(length=3)
|
|
231
|
-
manager = ZellijLocalManager(
|
|
231
|
+
manager = ZellijLocalManager(session_layouts=[LayoutConfig(layoutName="Agents", layoutTabs=tab_config)], session_name_prefix=random_name)
|
|
232
232
|
manager.start_all_sessions()
|
|
233
233
|
manager.run_monitoring_routine()
|
|
234
234
|
|
|
@@ -14,56 +14,27 @@ from machineconfig.scripts.python.helpers.helpers4 import get_import_module_code
|
|
|
14
14
|
from machineconfig.utils.ve import get_repo_root, get_ve_activate_line, get_ve_path_and_ipython_profile
|
|
15
15
|
from machineconfig.utils.options import display_options, choose_one_option
|
|
16
16
|
from machineconfig.utils.path import match_file_name, sanitize_path
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
from machineconfig.utils.path_reduced import PathExtended as PathExtended
|
|
19
19
|
from machineconfig.utils.io_save import save_toml
|
|
20
20
|
from machineconfig.utils.utils2 import randstr, read_toml
|
|
21
|
+
from machineconfig.scripts.python.fire_jobs_args_helper import get_args, FireJobArgs, extract_kwargs
|
|
21
22
|
import platform
|
|
22
23
|
from typing import Optional
|
|
23
|
-
import
|
|
24
|
-
import os
|
|
24
|
+
# import os
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
def main(args: FireJobArgs) -> None:
|
|
28
|
+
if args.layout:
|
|
29
|
+
from machineconfig.scripts.python.fire_jobs_layout_helper import handle_layout_args
|
|
28
30
|
|
|
31
|
+
return handle_layout_args(args)
|
|
29
32
|
|
|
30
|
-
def main() -> None:
|
|
31
|
-
parser = argparse.ArgumentParser()
|
|
32
|
-
parser.add_argument("path", nargs="?", type=str, help="The directory containing the jobs", default=".")
|
|
33
|
-
parser.add_argument("function", nargs="?", type=str, help="Fuction to run", default=None)
|
|
34
|
-
parser.add_argument("--ve", "-v", type=str, help="virtual enviroment name", default="")
|
|
35
|
-
parser.add_argument("--cmd", "-B", action="store_true", help="Create a cmd fire command to launch the the job asynchronously.")
|
|
36
|
-
parser.add_argument("--interactive", "-i", action="store_true", help="Whether to run the job interactively using IPython")
|
|
37
|
-
parser.add_argument("--debug", "-d", action="store_true", help="debug")
|
|
38
|
-
parser.add_argument("--choose_function", "-c", action="store_true", help="debug")
|
|
39
|
-
parser.add_argument("--loop", "-l", action="store_true", help="infinite recusion (runs again after completion/interruption)")
|
|
40
|
-
parser.add_argument("--jupyter", "-j", action="store_true", help="open in a jupyter notebook")
|
|
41
|
-
parser.add_argument("--submit_to_cloud", "-C", action="store_true", help="submit to cloud compute")
|
|
42
|
-
parser.add_argument("--remote", "-r", action="store_true", help="launch on a remote machine")
|
|
43
|
-
parser.add_argument("--module", "-m", action="store_true", help="launch the main file")
|
|
44
|
-
parser.add_argument("--streamlit", "-S", action="store_true", help="run as streamlit app")
|
|
45
|
-
parser.add_argument("--environment", "-E", type=str, help="Choose ip, localhost, hostname or arbitrary url", default="")
|
|
46
|
-
parser.add_argument("--holdDirectory", "-D", action="store_true", help="hold current directory and avoid cd'ing to the script directory")
|
|
47
|
-
parser.add_argument("--PathExport", "-P", action="store_true", help="augment the PYTHONPATH with repo root.")
|
|
48
|
-
parser.add_argument("--git_pull", "-g", action="store_true", help="Start by pulling the git repo")
|
|
49
|
-
parser.add_argument("--optimized", "-O", action="store_true", help="Run the optimized version of the function")
|
|
50
|
-
parser.add_argument("--Nprocess", "-p", type=int, help="Number of processes to use", default=1)
|
|
51
|
-
parser.add_argument("--zellij_tab", "-z", type=str, dest="zellij_tab", help="open in a new zellij tab")
|
|
52
|
-
parser.add_argument("--watch", "-w", action="store_true", help="watch the file for changes")
|
|
53
|
-
parser.add_argument("--kw", nargs="*", default=None, help="keyword arguments to pass to the function in the form of k1 v1 k2 v2 ... (meaning k1=v1, k2=v2, etc)")
|
|
54
|
-
try:
|
|
55
|
-
args = parser.parse_args()
|
|
56
|
-
except Exception as ex:
|
|
57
|
-
print(f"❌ Failed to parse arguments: {ex}")
|
|
58
|
-
parser.print_help()
|
|
59
|
-
raise ex
|
|
60
33
|
path_obj = sanitize_path(args.path)
|
|
61
|
-
# print(f"Passed path sanitied to {path_obj}")
|
|
62
34
|
if not path_obj.exists():
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if path_obj.is_dir():
|
|
35
|
+
suffixes = {".py", ".sh", ".ps1"}
|
|
36
|
+
choice_file = match_file_name(sub_string=args.path, search_root=PathExtended.cwd(), suffixes=suffixes)
|
|
37
|
+
elif path_obj.is_dir():
|
|
67
38
|
print(f"🔍 Searching recursively for Python, PowerShell and Shell scripts in directory `{path_obj}`")
|
|
68
39
|
files = search_for_files_of_interest(path_obj)
|
|
69
40
|
print(f"🔍 Got #{len(files)} results.")
|
|
@@ -73,24 +44,13 @@ def main() -> None:
|
|
|
73
44
|
choice_file = path_obj
|
|
74
45
|
repo_root = get_repo_root(str(choice_file))
|
|
75
46
|
print(f"💾 Selected file: {choice_file}.\nRepo root: {repo_root}")
|
|
76
|
-
|
|
77
47
|
ve_root_from_file, ipy_profile = get_ve_path_and_ipython_profile(choice_file)
|
|
78
48
|
if ipy_profile is None:
|
|
79
49
|
ipy_profile = "default"
|
|
80
50
|
activate_ve_line = get_ve_activate_line(ve_root=args.ve or ve_root_from_file or "$HOME/code/machineconfig/.venv")
|
|
81
51
|
|
|
82
|
-
# Convert args.kw to dictionary
|
|
83
52
|
if choice_file.suffix == ".py":
|
|
84
|
-
|
|
85
|
-
assert len(args.kw) % 2 == 0, f"args.kw must be a list of even length. Got {len(args.kw)}"
|
|
86
|
-
kwargs = dict(zip(args.kw[::2], args.kw[1::2]))
|
|
87
|
-
for key, value in kwargs.items():
|
|
88
|
-
if value in str2obj:
|
|
89
|
-
kwargs[key] = str2obj[value]
|
|
90
|
-
if args.function is None: # if user passed arguments and forgot to pass function, then assume they want to run the main function.
|
|
91
|
-
args.choose_function = True
|
|
92
|
-
else:
|
|
93
|
-
kwargs = {}
|
|
53
|
+
kwargs = extract_kwargs(args)
|
|
94
54
|
else:
|
|
95
55
|
kwargs = {}
|
|
96
56
|
|
|
@@ -296,22 +256,13 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
296
256
|
command += f"--function {choice_function} "
|
|
297
257
|
|
|
298
258
|
if args.Nprocess > 1:
|
|
299
|
-
# lines = [f""" zellij action new-tab --name nProcess{randstr(2)}"""]
|
|
300
|
-
# command = command.replace(". activate_ve", ". $HOME/scripts/activate_ve")
|
|
301
|
-
# for an_arg in range(args.Nprocess):
|
|
302
|
-
# sub_command = f"{command} --idx={an_arg} --idx_max={args.Nprocess}"
|
|
303
|
-
# if args.optimized:
|
|
304
|
-
# sub_command = sub_command.replace("python ", "python -OO ")
|
|
305
|
-
# sub_command_path = PathExtended.tmpfile(suffix=".sh").write_text(sub_command, encoding="utf-8")
|
|
306
|
-
# lines.append(f"""zellij action new-pane -- bash {sub_command_path} """)
|
|
307
|
-
# lines.append("sleep 5") # python tends to freeze if you launch instances within 1 microsecond of each other
|
|
308
|
-
# command = "\n".join(lines)
|
|
309
|
-
tab_config = {}
|
|
310
|
-
for an_arg in range(args.Nprocess):
|
|
311
|
-
tab_config[f"tab{an_arg}"] = (str(PathExtended.cwd()), f"uv run -m fire {choice_file} {choice_function} --idx={an_arg} --idx_max={args.Nprocess}")
|
|
312
259
|
from machineconfig.cluster.sessions_managers.zellij_local import run_zellij_layout
|
|
260
|
+
from machineconfig.cluster.sessions_managers.layout_types import LayoutConfig
|
|
313
261
|
|
|
314
|
-
|
|
262
|
+
layout: LayoutConfig = {"layoutName": "fireNprocess", "layoutTabs": []}
|
|
263
|
+
for an_arg in range(args.Nprocess):
|
|
264
|
+
layout["layoutTabs"].append({"tabName": f"tab{an_arg}", "startDir": str(PathExtended.cwd()), "command": f"uv run -m fire {choice_file} {choice_function} --idx={an_arg} --idx_max={args.Nprocess}"})
|
|
265
|
+
run_zellij_layout(layout_config=layout)
|
|
315
266
|
return None
|
|
316
267
|
|
|
317
268
|
if args.optimized:
|
|
@@ -356,8 +307,8 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
356
307
|
raise NotImplementedError(f"Platform {platform.system()} not supported.")
|
|
357
308
|
command = export_line + "\n" + command
|
|
358
309
|
|
|
359
|
-
program_path = os.environ.get("op_script", None)
|
|
360
|
-
program_path = PathExtended(program_path) if program_path is not None else PROGRAM_PATH
|
|
310
|
+
# program_path = os.environ.get("op_script", None)
|
|
311
|
+
# program_path = PathExtended(program_path) if program_path is not None else PROGRAM_PATH
|
|
361
312
|
if args.loop:
|
|
362
313
|
if platform.system() in ["Linux", "Darwin"]:
|
|
363
314
|
command = command + "\nsleep 0.5"
|
|
@@ -367,12 +318,15 @@ python -m machineconfig.cluster.templates.cli_click --file {choice_file} """
|
|
|
367
318
|
command = "$ErrorActionPreference = 'SilentlyContinue';\n" + command + "\nStart-Sleep -Seconds 0.5"
|
|
368
319
|
else:
|
|
369
320
|
raise NotImplementedError(f"Platform {platform.system()} not supported.")
|
|
370
|
-
command = command + f"\n. {program_path}"
|
|
371
|
-
console.print(Panel(Syntax(command, lexer="shell"), title=f"🔥 fire command @ {
|
|
372
|
-
program_path.parent.mkdir(parents=True, exist_ok=True)
|
|
373
|
-
program_path.write_text(command, encoding="utf-8")
|
|
321
|
+
# command = command + f"\n. {program_path}"
|
|
322
|
+
console.print(Panel(Syntax(command, lexer="shell"), title=f"🔥 fire command @ {command}: "), style="bold red")
|
|
323
|
+
# program_path.parent.mkdir(parents=True, exist_ok=True)
|
|
324
|
+
# program_path.write_text(command, encoding="utf-8")
|
|
325
|
+
import subprocess
|
|
326
|
+
subprocess.run(command, shell=True, check=True)
|
|
374
327
|
|
|
375
328
|
|
|
376
329
|
if __name__ == "__main__":
|
|
377
330
|
# options, func_args = parse_pyfile(file_path="C:/Users/aalsaf01/code/machineconfig/myresources/crocodile/core.py")
|
|
378
|
-
|
|
331
|
+
args = get_args()
|
|
332
|
+
main(args)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass
|
|
7
|
+
class FireJobArgs:
|
|
8
|
+
"""Type-safe dataclass for fire_jobs command line arguments."""
|
|
9
|
+
|
|
10
|
+
path: str = "."
|
|
11
|
+
function: Optional[str] = None
|
|
12
|
+
ve: str = ""
|
|
13
|
+
cmd: bool = False
|
|
14
|
+
interactive: bool = False
|
|
15
|
+
debug: bool = False
|
|
16
|
+
choose_function: bool = False
|
|
17
|
+
loop: bool = False
|
|
18
|
+
jupyter: bool = False
|
|
19
|
+
submit_to_cloud: bool = False
|
|
20
|
+
remote: bool = False
|
|
21
|
+
module: bool = False
|
|
22
|
+
streamlit: bool = False
|
|
23
|
+
environment: str = ""
|
|
24
|
+
holdDirectory: bool = False
|
|
25
|
+
PathExport: bool = False
|
|
26
|
+
git_pull: bool = False
|
|
27
|
+
optimized: bool = False
|
|
28
|
+
Nprocess: int = 1
|
|
29
|
+
zellij_tab: Optional[str] = None
|
|
30
|
+
watch: bool = False
|
|
31
|
+
kw: Optional[list[str]] = None
|
|
32
|
+
layout: bool = False
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_args() -> FireJobArgs:
|
|
36
|
+
parser = argparse.ArgumentParser()
|
|
37
|
+
parser.add_argument("path", nargs="?", type=str, help="The directory containing the jobs", default=".")
|
|
38
|
+
parser.add_argument("function", nargs="?", type=str, help="Fuction to run", default=None)
|
|
39
|
+
parser.add_argument("--ve", "-v", type=str, help="virtual enviroment name", default="")
|
|
40
|
+
parser.add_argument("--cmd", "-B", action="store_true", help="Create a cmd fire command to launch the the job asynchronously.")
|
|
41
|
+
parser.add_argument("--interactive", "-i", action="store_true", help="Whether to run the job interactively using IPython")
|
|
42
|
+
parser.add_argument("--debug", "-d", action="store_true", help="debug")
|
|
43
|
+
parser.add_argument("--choose_function", "-c", action="store_true", help="debug")
|
|
44
|
+
parser.add_argument("--loop", "-l", action="store_true", help="infinite recusion (runs again after completion/interruption)")
|
|
45
|
+
parser.add_argument("--jupyter", "-j", action="store_true", help="open in a jupyter notebook")
|
|
46
|
+
parser.add_argument("--submit_to_cloud", "-C", action="store_true", help="submit to cloud compute")
|
|
47
|
+
parser.add_argument("--remote", "-r", action="store_true", help="launch on a remote machine")
|
|
48
|
+
parser.add_argument("--module", "-m", action="store_true", help="launch the main file")
|
|
49
|
+
parser.add_argument("--streamlit", "-S", action="store_true", help="run as streamlit app")
|
|
50
|
+
parser.add_argument("--environment", "-E", type=str, help="Choose ip, localhost, hostname or arbitrary url", default="")
|
|
51
|
+
parser.add_argument("--holdDirectory", "-D", action="store_true", help="hold current directory and avoid cd'ing to the script directory")
|
|
52
|
+
parser.add_argument("--PathExport", "-P", action="store_true", help="augment the PYTHONPATH with repo root.")
|
|
53
|
+
parser.add_argument("--git_pull", "-g", action="store_true", help="Start by pulling the git repo")
|
|
54
|
+
parser.add_argument("--optimized", "-O", action="store_true", help="Run the optimized version of the function")
|
|
55
|
+
parser.add_argument("--Nprocess", "-p", type=int, help="Number of processes to use", default=1)
|
|
56
|
+
parser.add_argument("--zellij_tab", "-z", type=str, dest="zellij_tab", help="open in a new zellij tab")
|
|
57
|
+
parser.add_argument("--watch", "-w", action="store_true", help="watch the file for changes")
|
|
58
|
+
parser.add_argument("--kw", nargs="*", default=None, help="keyword arguments to pass to the function in the form of k1 v1 k2 v2 ... (meaning k1=v1, k2=v2, etc)")
|
|
59
|
+
parser.add_argument("--layout", "-L", action="store_true", help="use layout configuration (Zellij Or WindowsTerminal)")
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
args_raw = parser.parse_args()
|
|
63
|
+
except Exception as ex:
|
|
64
|
+
print(f"❌ Failed to parse arguments: {ex}")
|
|
65
|
+
parser.print_help()
|
|
66
|
+
raise ex
|
|
67
|
+
args = FireJobArgs(**vars(args_raw))
|
|
68
|
+
return args
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def extract_kwargs(args: FireJobArgs) -> dict[str, object]:
|
|
72
|
+
str2obj = {"True": True, "False": False, "None": None}
|
|
73
|
+
if args.kw is not None:
|
|
74
|
+
assert len(args.kw) % 2 == 0, f"args.kw must be a list of even length. Got {len(args.kw)}"
|
|
75
|
+
kwargs = dict(zip(args.kw[::2], args.kw[1::2]))
|
|
76
|
+
kwargs: dict[str, object]
|
|
77
|
+
for key, value in kwargs.items():
|
|
78
|
+
if value in str2obj:
|
|
79
|
+
kwargs[key] = str2obj[str(value)]
|
|
80
|
+
if args.function is None: # if user passed arguments and forgot to pass function, then assume they want to run the main function.
|
|
81
|
+
args.choose_function = True
|
|
82
|
+
else:
|
|
83
|
+
kwargs = {}
|
|
84
|
+
return kwargs
|