machineconfig 7.57__py3-none-any.whl → 7.79__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/cluster/sessions_managers/utils/maker.py +21 -9
- machineconfig/jobs/installer/custom/boxes.py +2 -2
- machineconfig/jobs/installer/custom/hx.py +3 -3
- machineconfig/jobs/installer/custom_dev/cloudflare_warp_cli.py +23 -0
- machineconfig/jobs/installer/custom_dev/dubdb_adbc.py +1 -1
- machineconfig/jobs/installer/custom_dev/nerfont_windows_helper.py +1 -1
- machineconfig/jobs/installer/custom_dev/sysabc.py +36 -28
- machineconfig/jobs/installer/custom_dev/wezterm.py +0 -4
- machineconfig/jobs/installer/installer_data.json +127 -25
- machineconfig/jobs/installer/package_groups.py +20 -13
- machineconfig/profile/create_links_export.py +2 -2
- machineconfig/scripts/__init__.py +0 -4
- machineconfig/scripts/linux/wrap_mcfg +1 -1
- machineconfig/scripts/python/agents.py +22 -17
- machineconfig/scripts/python/ai/solutions/copilot/instructions/python/dev.instructions.md +3 -0
- machineconfig/scripts/python/croshell.py +22 -17
- machineconfig/scripts/python/devops.py +3 -4
- machineconfig/scripts/python/devops_navigator.py +0 -4
- machineconfig/scripts/python/env_manager/path_manager_tui.py +1 -1
- machineconfig/scripts/python/fire_jobs.py +19 -18
- machineconfig/scripts/python/ftpx.py +36 -12
- machineconfig/scripts/python/helpers/ast_search.py +74 -0
- machineconfig/scripts/python/helpers/qr_code.py +166 -0
- machineconfig/scripts/python/helpers/repo_rag.py +325 -0
- machineconfig/scripts/python/helpers/symantic_search.py +25 -0
- machineconfig/scripts/python/helpers_cloud/cloud_copy.py +28 -21
- machineconfig/scripts/python/helpers_cloud/cloud_helpers.py +1 -1
- machineconfig/scripts/python/helpers_cloud/cloud_mount.py +19 -17
- machineconfig/scripts/python/helpers_cloud/cloud_sync.py +8 -7
- machineconfig/scripts/python/helpers_croshell/crosh.py +2 -2
- machineconfig/scripts/python/helpers_croshell/start_slidev.py +6 -7
- machineconfig/scripts/python/helpers_devops/cli_config_dotfile.py +4 -5
- machineconfig/scripts/python/helpers_devops/cli_nw.py +88 -7
- machineconfig/scripts/python/helpers_devops/cli_self.py +7 -6
- machineconfig/scripts/python/helpers_devops/cli_share_file.py +9 -9
- machineconfig/scripts/python/helpers_devops/cli_share_server.py +13 -12
- machineconfig/scripts/python/helpers_devops/cli_terminal.py +7 -6
- machineconfig/scripts/python/helpers_devops/cli_utils.py +2 -73
- machineconfig/scripts/python/helpers_devops/devops_backup_retrieve.py +4 -4
- machineconfig/scripts/python/helpers_devops/devops_status.py +7 -19
- machineconfig/scripts/python/helpers_fire_command/file_wrangler.py +2 -3
- machineconfig/scripts/python/helpers_fire_command/fire_jobs_route_helper.py +23 -13
- machineconfig/scripts/python/helpers_navigator/command_tree.py +50 -18
- machineconfig/scripts/python/helpers_repos/cloud_repo_sync.py +7 -4
- machineconfig/scripts/python/helpers_repos/count_lines_frontend.py +1 -1
- machineconfig/scripts/python/helpers_repos/entrypoint.py +2 -1
- machineconfig/scripts/python/helpers_repos/record.py +2 -1
- machineconfig/scripts/python/helpers_sessions/sessions_multiprocess.py +5 -5
- machineconfig/scripts/python/helpers_utils/download.py +152 -0
- machineconfig/scripts/python/helpers_utils/path.py +81 -31
- machineconfig/scripts/python/interactive.py +2 -2
- machineconfig/scripts/python/{machineconfig.py → mcfg_entry.py} +4 -0
- machineconfig/scripts/python/msearch.py +21 -2
- machineconfig/scripts/python/nw/address.py +132 -0
- machineconfig/scripts/python/nw/devops_add_ssh_key.py +8 -5
- machineconfig/scripts/python/nw/ssh_debug_linux.py +7 -7
- machineconfig/scripts/python/nw/ssh_debug_windows.py +4 -4
- machineconfig/scripts/python/nw/wsl_windows_transfer.py +3 -2
- machineconfig/scripts/python/sessions.py +35 -20
- machineconfig/scripts/python/terminal.py +2 -2
- machineconfig/scripts/python/utils.py +12 -10
- machineconfig/scripts/windows/mounts/mount_ssh.ps1 +1 -1
- machineconfig/settings/lf/windows/lfcd.ps1 +1 -1
- machineconfig/settings/shells/nushell/config.nu +2 -2
- machineconfig/settings/shells/nushell/env.nu +45 -6
- machineconfig/settings/shells/nushell/init.nu +282 -95
- machineconfig/settings/shells/pwsh/init.ps1 +1 -0
- machineconfig/settings/shells/zsh/init.sh +0 -7
- machineconfig/setup_linux/web_shortcuts/interactive.sh +10 -10
- machineconfig/setup_windows/uv.ps1 +8 -1
- machineconfig/setup_windows/web_shortcuts/interactive.ps1 +10 -10
- machineconfig/setup_windows/web_shortcuts/quick_init.ps1 +3 -2
- machineconfig/utils/accessories.py +7 -4
- machineconfig/utils/code.py +6 -4
- machineconfig/utils/files/headers.py +2 -2
- machineconfig/utils/installer_utils/install_from_url.py +180 -0
- machineconfig/utils/installer_utils/installer_class.py +53 -47
- machineconfig/utils/installer_utils/{installer.py → installer_cli.py} +71 -65
- machineconfig/utils/{installer.py → installer_utils/installer_runner.py} +1 -25
- machineconfig/utils/links.py +2 -2
- machineconfig/utils/meta.py +30 -16
- machineconfig/utils/options.py +4 -4
- machineconfig/utils/path_extended.py +3 -3
- machineconfig/utils/path_helper.py +33 -31
- machineconfig/utils/schemas/layouts/layout_types.py +1 -1
- machineconfig/utils/ssh.py +143 -409
- machineconfig/utils/ssh_utils/abc.py +8 -0
- machineconfig/utils/ssh_utils/copy_from_here.py +110 -0
- machineconfig/utils/ssh_utils/copy_to_here.py +302 -0
- machineconfig/utils/ssh_utils/utils.py +141 -0
- machineconfig/utils/ssh_utils/wsl.py +168 -0
- machineconfig/utils/upgrade_packages.py +2 -1
- machineconfig/utils/ve.py +11 -4
- {machineconfig-7.57.dist-info → machineconfig-7.79.dist-info}/METADATA +1 -1
- {machineconfig-7.57.dist-info → machineconfig-7.79.dist-info}/RECORD +102 -92
- {machineconfig-7.57.dist-info → machineconfig-7.79.dist-info}/entry_points.txt +2 -2
- machineconfig/jobs/installer/linux_scripts/pgsql.sh +0 -41
- machineconfig/scripts/python/explore.py +0 -49
- /machineconfig/jobs/installer/linux_scripts/{warp-cli.sh → cloudflare_warp_cli.sh} +0 -0
- /machineconfig/{settings/shells/pwsh/profile.ps1 → scripts/python/helpers_fire_command/f.py} +0 -0
- /machineconfig/scripts/{Restore-ThunderbirdProfile.ps1 → windows/mounts/Restore-ThunderbirdProfile.ps1} +0 -0
- /machineconfig/utils/installer_utils/{installer_abc.py → installer_locator_utils.py} +0 -0
- {machineconfig-7.57.dist-info → machineconfig-7.79.dist-info}/WHEEL +0 -0
- {machineconfig-7.57.dist-info → machineconfig-7.79.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from pathlib import Path
|
|
6
5
|
from typing import cast, Optional, get_args, Annotated
|
|
7
6
|
import typer
|
|
8
7
|
from machineconfig.scripts.python.helpers_agents.fire_agents_helper_types import AGENTS, HOST, PROVIDER
|
|
@@ -13,22 +12,22 @@ def create(
|
|
|
13
12
|
host: Annotated[HOST, typer.Option(..., "--host", "-h", help=f"Machine to run agents on. One of {', '.join(get_args(HOST))}")],
|
|
14
13
|
model: Annotated[str, typer.Option(..., "--model", "-m", help="Model to use (for crush agent).")],
|
|
15
14
|
provider: Annotated[PROVIDER, typer.Option(..., "--provider", "-p", help=f"Provider to use (for crush agent). One of {', '.join(get_args(PROVIDER)[:3])}")],
|
|
16
|
-
context_path: Annotated[Optional[
|
|
15
|
+
context_path: Annotated[Optional[str], typer.Option(..., "--context-path", "-c", help="Path to the context file/folder, defaults to .ai/todo/")] = None,
|
|
17
16
|
separator: Annotated[str, typer.Option(..., "--separator", "-s", help="Separator for context")] = "\n",
|
|
18
17
|
agent_load: Annotated[int, typer.Option(..., "--agent-load", "-al", help="Number of tasks per prompt")] = 13,
|
|
19
18
|
prompt: Annotated[Optional[str], typer.Option(..., "--prompt", "-P", help="Prompt prefix as string")] = None,
|
|
20
|
-
prompt_path: Annotated[Optional[
|
|
19
|
+
prompt_path: Annotated[Optional[str], typer.Option(..., "--prompt-path", "-pp", help="Path to prompt file")] = None,
|
|
21
20
|
job_name: Annotated[str, typer.Option(..., "--job-name", "-j", help="Job name")] = "AI_Agents",
|
|
22
21
|
separate: Annotated[bool, typer.Option(..., "--separate", "-S", help="Keep prompt material in separate file to the context.")] = True,
|
|
23
|
-
output_path: Annotated[Optional[
|
|
24
|
-
agents_dir: Annotated[Optional[
|
|
22
|
+
output_path: Annotated[Optional[str], typer.Option(..., "--output-path", "-o", help="Path to write the layout.json file")] = None,
|
|
23
|
+
agents_dir: Annotated[Optional[str], typer.Option(..., "--agents-dir", "-ad", help="Directory to store agent files. If not provided, will be constructed automatically.")] = None,
|
|
25
24
|
):
|
|
26
25
|
|
|
27
26
|
from machineconfig.scripts.python.helpers_agents.fire_agents_help_launch import prep_agent_launch, get_agents_launch_layout
|
|
28
27
|
from machineconfig.scripts.python.helpers_agents.fire_agents_load_balancer import chunk_prompts
|
|
29
28
|
from machineconfig.utils.accessories import get_repo_root, randstr
|
|
30
29
|
import json
|
|
31
|
-
|
|
30
|
+
from pathlib import Path
|
|
32
31
|
# validate mutual exclusive
|
|
33
32
|
prompt_options = [prompt, prompt_path]
|
|
34
33
|
provided_prompt = [opt for opt in prompt_options if opt is not None]
|
|
@@ -39,12 +38,13 @@ def create(
|
|
|
39
38
|
if repo_root is None:
|
|
40
39
|
typer.echo("💥 Could not determine the repository root. Please run this script from within a git repository.")
|
|
41
40
|
raise typer.Exit(1)
|
|
41
|
+
return
|
|
42
42
|
typer.echo(f"Operating @ {repo_root}")
|
|
43
43
|
|
|
44
44
|
if context_path is None:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
context_path_resolved = Path(repo_root) / ".ai" / "todo"
|
|
46
|
+
else: context_path_resolved = Path(context_path).expanduser().resolve()
|
|
47
|
+
|
|
48
48
|
if not context_path_resolved.exists():
|
|
49
49
|
raise typer.BadParameter(f"Path does not exist: {context_path_resolved}")
|
|
50
50
|
|
|
@@ -60,20 +60,21 @@ def create(
|
|
|
60
60
|
raise typer.BadParameter(f"Path is neither file nor directory: {context_path_resolved}")
|
|
61
61
|
|
|
62
62
|
if prompt_path is not None:
|
|
63
|
-
prompt_prefix = prompt_path.read_text(encoding="utf-8")
|
|
63
|
+
prompt_prefix = Path(prompt_path).read_text(encoding="utf-8")
|
|
64
64
|
else:
|
|
65
65
|
prompt_prefix = cast(str, prompt)
|
|
66
66
|
agent_selected = agent
|
|
67
|
-
if agents_dir is None:
|
|
67
|
+
if agents_dir is None: agents_dir_obj = Path(repo_root) / ".ai" / f"tmp_prompts/{job_name}_{randstr()}"
|
|
68
68
|
else:
|
|
69
69
|
import shutil
|
|
70
|
-
if agents_dir.exists():
|
|
70
|
+
if Path(agents_dir).exists():
|
|
71
71
|
shutil.rmtree(agents_dir)
|
|
72
|
-
|
|
72
|
+
agents_dir_obj = Path(agents_dir)
|
|
73
|
+
prep_agent_launch(repo_root=repo_root, agents_dir=agents_dir_obj, prompts_material=prompt_material_re_splitted,
|
|
73
74
|
keep_material_in_separate_file=separate,
|
|
74
75
|
prompt_prefix=prompt_prefix, machine=host, agent=agent_selected, model=model, provider=provider,
|
|
75
76
|
job_name=job_name)
|
|
76
|
-
layoutfile = get_agents_launch_layout(session_root=
|
|
77
|
+
layoutfile = get_agents_launch_layout(session_root=agents_dir_obj)
|
|
77
78
|
regenerate_py_code = f"""
|
|
78
79
|
#!/usr/bin/env uv run --python 3.14 --with machineconfig
|
|
79
80
|
agents create "{context_path_resolved}" \\
|
|
@@ -85,11 +86,11 @@ agents create "{context_path_resolved}" \\
|
|
|
85
86
|
--separator "{separator}" \\
|
|
86
87
|
{"--separate" if separate else ""}
|
|
87
88
|
"""
|
|
88
|
-
(
|
|
89
|
-
layout_output_path = output_path if output_path is not None else
|
|
89
|
+
(agents_dir_obj / "aa_agents_relaunch.sh").write_text(data=regenerate_py_code, encoding="utf-8")
|
|
90
|
+
layout_output_path = Path(output_path) if output_path is not None else agents_dir_obj / "layout.json"
|
|
90
91
|
layout_output_path.parent.mkdir(parents=True, exist_ok=True)
|
|
91
92
|
layout_output_path.write_text(data=json.dumps(layoutfile, indent=4), encoding="utf-8")
|
|
92
|
-
typer.echo(f"Created agents in {
|
|
93
|
+
typer.echo(f"Created agents in {agents_dir_obj}")
|
|
93
94
|
typer.echo(f"Ceated layout in {layout_output_path}")
|
|
94
95
|
|
|
95
96
|
|
|
@@ -99,6 +100,7 @@ def collect(
|
|
|
99
100
|
separator: Annotated[str, typer.Option(..., help="Separator to use when concatenating material files")] = "\n",
|
|
100
101
|
) -> None:
|
|
101
102
|
"""Collect all material files from an agent directory and concatenate them."""
|
|
103
|
+
from pathlib import Path
|
|
102
104
|
if not Path(agent_dir).exists() or not Path(agent_dir).is_dir():
|
|
103
105
|
raise typer.BadParameter(f"Agent directory does not exist or is not a directory: {agent_dir}")
|
|
104
106
|
|
|
@@ -137,6 +139,7 @@ def collect(
|
|
|
137
139
|
def template():
|
|
138
140
|
from platform import system
|
|
139
141
|
import machineconfig.scripts.python.helpers_agents as module
|
|
142
|
+
from pathlib import Path
|
|
140
143
|
if system() == "Linux" or system() == "Darwin":
|
|
141
144
|
template_path = Path(module.__file__).parent / "templates/template.sh"
|
|
142
145
|
elif system() == "Windows":
|
|
@@ -157,8 +160,10 @@ def template():
|
|
|
157
160
|
|
|
158
161
|
def init_config():
|
|
159
162
|
from machineconfig.scripts.python.ai.initai import add_ai_configs
|
|
163
|
+
from pathlib import Path
|
|
160
164
|
add_ai_configs(repo_root=Path.cwd())
|
|
161
165
|
|
|
166
|
+
|
|
162
167
|
def get_app():
|
|
163
168
|
agents_app = typer.Typer(help="🤖 AI Agents management subcommands", no_args_is_help=True, add_help_option=False, add_completion=False)
|
|
164
169
|
sep = "\n"
|
|
@@ -43,3 +43,6 @@ applyTo: "**/*.py"
|
|
|
43
43
|
* Please avoid writing README files and avoid docstring and comments in code unless absolutely necessary. Use clear naming conventions instead of documenting.
|
|
44
44
|
* Always prefer to functional style of programming over OOP.
|
|
45
45
|
* When passing arguments or constructing dicts or lists or tuples, avoid breaking lines too much, try to use ~ 150 characters per line before breaking to new one.
|
|
46
|
+
|
|
47
|
+
# Privacy:
|
|
48
|
+
* No matter what, never ever open/read/write/list anything under ~/dotfiles
|
|
@@ -16,13 +16,15 @@ def croshell(
|
|
|
16
16
|
jupyter: Annotated[bool, typer.Option("--jupyter", "-j", help="run in jupyter interactive console")] = False,
|
|
17
17
|
vscode: Annotated[bool, typer.Option("--vscode", "-c", help="open the script in vscode")] = False,
|
|
18
18
|
# streamlit_viewer: Annotated[bool, typer.Option("--streamlit", "-s", help="view in streamlit app")] = False,
|
|
19
|
+
uv_with: Annotated[Optional[str], typer.Option("--uv-with", "-w", help="specify uv with packages to use")] = None,
|
|
19
20
|
visidata: Annotated[bool, typer.Option("--visidata", "-v", help="open data file in visidata")] = False,
|
|
20
21
|
marimo: Annotated[bool, typer.Option("--marimo", "-m", help="open the notebook using marimo if available")] = False,
|
|
21
22
|
) -> None:
|
|
23
|
+
if uv_with is not None: user_uv_with_line = f"--with {uv_with} "
|
|
24
|
+
else: user_uv_with_line = ""
|
|
25
|
+
|
|
22
26
|
from machineconfig.scripts.python.helpers_croshell.crosh import get_read_python_file_pycode, get_read_data_pycode
|
|
23
27
|
from machineconfig.utils.meta import lambda_to_python_script
|
|
24
|
-
from machineconfig.utils.path_helper import get_choice_file
|
|
25
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
26
28
|
from pathlib import Path
|
|
27
29
|
from machineconfig.utils.accessories import randstr
|
|
28
30
|
import json
|
|
@@ -37,13 +39,15 @@ def croshell(
|
|
|
37
39
|
ipython_profile: Optional[str] = profile
|
|
38
40
|
file_obj = Path.cwd() # initialization value, could be modified according to args.
|
|
39
41
|
if path is not None:
|
|
42
|
+
from machineconfig.utils.path_helper import get_choice_file
|
|
40
43
|
choice_file = get_choice_file(path=path, suffixes={".*"})
|
|
41
44
|
if choice_file.suffix == ".py":
|
|
42
45
|
program = choice_file.read_text(encoding="utf-8")
|
|
43
46
|
text = f"📄 Selected file: {choice_file.name}"
|
|
44
47
|
console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
45
48
|
else:
|
|
46
|
-
program = lambda_to_python_script(lambda: get_read_data_pycode(path=str(choice_file)),
|
|
49
|
+
program = lambda_to_python_script(lambda: get_read_data_pycode(path=str(choice_file)),
|
|
50
|
+
in_global=True, import_module=False)
|
|
47
51
|
text = f"📄 Reading data from: {file_obj.name}"
|
|
48
52
|
console.print(Panel(text, title="[bold blue]Info[/bold blue]"))
|
|
49
53
|
else: # if nothing is specified, then run in interactive mode.
|
|
@@ -64,11 +68,12 @@ def croshell(
|
|
|
64
68
|
return textwrap.dedent("\n".join(inspect.getsource(f).splitlines()[1:]))
|
|
65
69
|
preprogram += get_body_simple_function_no_args(preprogram_func)
|
|
66
70
|
|
|
67
|
-
|
|
71
|
+
from pathlib import Path
|
|
72
|
+
pyfile = Path.home().joinpath(f"tmp_results/tmp_scripts/python/croshell/{randstr()}/script.py")
|
|
68
73
|
pyfile.parent.mkdir(parents=True, exist_ok=True)
|
|
69
|
-
|
|
70
74
|
title = "Reading Data"
|
|
71
|
-
def_code = lambda_to_python_script(lambda: get_read_python_file_pycode(path=str(pyfile), title=title),
|
|
75
|
+
def_code = lambda_to_python_script(lambda: get_read_python_file_pycode(path=str(pyfile), title=title),
|
|
76
|
+
in_global=False, import_module=False)
|
|
72
77
|
# print(def_code)
|
|
73
78
|
python_program = preprogram + "\n\n" + def_code + program
|
|
74
79
|
pyfile.write_text(python_program, encoding="utf-8")
|
|
@@ -102,37 +107,37 @@ def croshell(
|
|
|
102
107
|
pass
|
|
103
108
|
if visidata:
|
|
104
109
|
if file_obj.suffix == ".json":
|
|
105
|
-
fire_line = f"uv run --python 3.14 --with visidata vd {str(file_obj)}"
|
|
110
|
+
fire_line = f"uv run --python 3.14 {user_uv_with_line} --with visidata vd {str(file_obj)}"
|
|
106
111
|
else:
|
|
107
|
-
fire_line = f"uv run --python 3.14 --with visidata,pyarrow vd {str(file_obj)}"
|
|
112
|
+
fire_line = f"uv run --python 3.14 {user_uv_with_line}--with visidata,pyarrow vd {str(file_obj)}"
|
|
108
113
|
elif marimo:
|
|
109
|
-
if Path.home().joinpath("code/machineconfig").exists(): requirements = f"""--with marimo --project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
110
|
-
else: requirements = """--python 3.14 --with "marimo,cowsay,machineconfig[plot]>=7.
|
|
114
|
+
if Path.home().joinpath("code/machineconfig").exists(): requirements = f"""{user_uv_with_line} --with marimo --project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
115
|
+
else: requirements = f"""--python 3.14 {user_uv_with_line} user_uv_with_line--with "marimo,cowsay,machineconfig[plot]>=7.79" """
|
|
111
116
|
fire_line = f"""
|
|
112
117
|
cd {str(pyfile.parent)}
|
|
113
118
|
uv run --python 3.14 --with "marimo" marimo convert {pyfile.name} -o marimo_nb.py
|
|
114
119
|
uv run {requirements} marimo edit --host 0.0.0.0 marimo_nb.py
|
|
115
120
|
"""
|
|
116
121
|
elif jupyter:
|
|
117
|
-
if Path.home().joinpath("code/machineconfig").exists(): requirements = f"""--project "{str(Path.home().joinpath("code/machineconfig"))}"
|
|
118
|
-
else: requirements = """--with "cowsay,machineconfig[plot]>=7.
|
|
122
|
+
if Path.home().joinpath("code/machineconfig").exists(): requirements = f"""{user_uv_with_line} --with jupyterlab --project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
123
|
+
else: requirements = f"""{user_uv_with_line} --with "cowsay,machineconfig[plot]>=7.79" """
|
|
119
124
|
fire_line = f"uv run {requirements} jupyter-lab {str(nb_target)}"
|
|
120
125
|
elif vscode:
|
|
126
|
+
user_uv_add = f"uv add {uv_with}" if uv_with is not None else ""
|
|
121
127
|
fire_line = f"""
|
|
122
128
|
cd {str(pyfile.parent)}
|
|
123
129
|
uv init --python 3.14
|
|
124
130
|
uv venv
|
|
125
|
-
uv add "cowsay,machineconfig[plot]>=7.
|
|
131
|
+
uv add "cowsay,machineconfig[plot]>=7.79"
|
|
132
|
+
uv add {user_uv_add}
|
|
126
133
|
# code serve-web
|
|
127
134
|
code --new-window {str(pyfile)}
|
|
128
135
|
"""
|
|
129
136
|
else:
|
|
130
137
|
if interpreter == "ipython": profile = f" --profile {ipython_profile} --no-banner"
|
|
131
138
|
else: profile = ""
|
|
132
|
-
if Path.home().joinpath("code/machineconfig").exists(): ve_line = f"""--project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
133
|
-
else: ve_line = """--python 3.14 --with "cowsay,machineconfig[plot]>=7.
|
|
134
|
-
# ve_path_maybe, ipython_profile_maybe = get_ve_path_and_ipython_profile(Path.cwd())
|
|
135
|
-
# --python 3.14
|
|
139
|
+
if Path.home().joinpath("code/machineconfig").exists(): ve_line = f"""{user_uv_with_line} --project "{str(Path.home().joinpath("code/machineconfig"))}" """
|
|
140
|
+
else: ve_line = f"""--python 3.14 {user_uv_with_line} --with "cowsay,machineconfig[plot]>=7.79" """
|
|
136
141
|
fire_line = f"uv run {ve_line} {interpreter} {interactivity} {profile} {str(pyfile)}"
|
|
137
142
|
|
|
138
143
|
from machineconfig.utils.code import exit_then_run_shell_script
|
|
@@ -12,17 +12,16 @@ import machineconfig.scripts.python.helpers_devops.cli_nw as cli_network
|
|
|
12
12
|
|
|
13
13
|
def install(which: Annotated[Optional[str], typer.Argument(..., help="Comma-separated list of program names to install, or group name if --group flag is set.")] = None,
|
|
14
14
|
group: Annotated[bool, typer.Option(..., "--group", "-g", help="Treat 'which' as a group name. A group is bundle of apps.")] = False,
|
|
15
|
-
interactive: Annotated[bool, typer.Option(..., "--interactive", "-
|
|
15
|
+
interactive: Annotated[bool, typer.Option(..., "--interactive", "-i", help="Interactive selection of programs to install.")] = False,
|
|
16
16
|
) -> None:
|
|
17
17
|
"""📦 Install packages"""
|
|
18
|
-
import machineconfig.utils.installer_utils.
|
|
19
|
-
installer_entry_point.
|
|
18
|
+
import machineconfig.utils.installer_utils.installer_cli as installer_entry_point
|
|
19
|
+
installer_entry_point.main_installer_cli(which=which, group=group, interactive=interactive)
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def get_app():
|
|
23
23
|
app = typer.Typer(help="🛠️ DevOps operations", no_args_is_help=True, add_help_option=False,
|
|
24
24
|
add_completion=False)
|
|
25
|
-
_ = install
|
|
26
25
|
app.command("install", no_args_is_help=True, help="🛠️ [i] Install essential packages")(install)
|
|
27
26
|
app.command("i", no_args_is_help=True, help="Install essential packages", hidden=True)(install)
|
|
28
27
|
app_repos = cli_repos.get_app()
|
|
@@ -7,20 +7,16 @@ fire
|
|
|
7
7
|
|
|
8
8
|
"""
|
|
9
9
|
|
|
10
|
-
from machineconfig.utils.ve import get_ve_path_and_ipython_profile
|
|
11
|
-
from machineconfig.utils.accessories import get_repo_root, randstr
|
|
12
|
-
from machineconfig.scripts.python.helpers_fire_command.fire_jobs_args_helper import FireJobArgs, extract_kwargs, parse_fire_args_from_context
|
|
13
|
-
from machineconfig.utils.path_helper import get_choice_file
|
|
14
|
-
|
|
15
|
-
import platform
|
|
16
10
|
from typing import Optional, Annotated
|
|
17
|
-
from pathlib import Path
|
|
18
11
|
import typer
|
|
19
12
|
|
|
20
13
|
|
|
21
|
-
def route(args: FireJobArgs, fire_args: str = "") -> None:
|
|
14
|
+
def route(args: "FireJobArgs", fire_args: str = "") -> None:
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from machineconfig.utils.path_helper import get_choice_file
|
|
17
|
+
from machineconfig.utils.accessories import get_repo_root, randstr
|
|
22
18
|
choice_file = get_choice_file(args.path, suffixes=None)
|
|
23
|
-
repo_root = get_repo_root(
|
|
19
|
+
repo_root = get_repo_root(choice_file)
|
|
24
20
|
print(f"💾 Selected file: {choice_file}.\nRepo root: {repo_root}")
|
|
25
21
|
if args.marimo:
|
|
26
22
|
print(f"🧽 Preparing to launch Marimo notebook for `{choice_file}`...")
|
|
@@ -32,13 +28,13 @@ uv run --python 3.14 --with marimo marimo convert {choice_file} -o marimo_nb.py
|
|
|
32
28
|
uv run --project {repo_root} --with marimo marimo edit --host 0.0.0.0 marimo_nb.py
|
|
33
29
|
"""
|
|
34
30
|
from machineconfig.utils.code import exit_then_run_shell_script
|
|
35
|
-
|
|
36
31
|
print(f"🚀 Launching Marimo notebook for `{choice_file}`...")
|
|
37
32
|
exit_then_run_shell_script(script)
|
|
38
33
|
return
|
|
39
34
|
|
|
40
35
|
# ========================= preparing kwargs_dict
|
|
41
36
|
if choice_file.suffix == ".py":
|
|
37
|
+
from machineconfig.scripts.python.helpers_fire_command.fire_jobs_args_helper import extract_kwargs
|
|
42
38
|
kwargs_dict = extract_kwargs(args) # This now returns empty dict, but kept for compatibility
|
|
43
39
|
else:
|
|
44
40
|
kwargs_dict = {}
|
|
@@ -53,17 +49,17 @@ uv run --project {repo_root} --with marimo marimo edit --host 0.0.0.0 marimo_nb.
|
|
|
53
49
|
choice_function = args.function
|
|
54
50
|
|
|
55
51
|
if choice_file.suffix == ".py":
|
|
56
|
-
from machineconfig.scripts.python.helpers_fire_command.fire_jobs_route_helper import get_command_streamlit
|
|
57
|
-
|
|
58
52
|
with_project = f"--project {repo_root} " if repo_root is not None else ""
|
|
59
53
|
if args.streamlit:
|
|
54
|
+
from machineconfig.scripts.python.helpers_fire_command.fire_jobs_route_helper import get_command_streamlit
|
|
60
55
|
exe = get_command_streamlit(choice_file=choice_file, environment=args.environment, repo_root=repo_root)
|
|
61
56
|
exe = f"uv run {with_project} {exe} "
|
|
62
57
|
elif args.jupyter:
|
|
63
58
|
exe = f"uv run {with_project} jupyter-lab"
|
|
64
59
|
else:
|
|
65
60
|
if args.interactive:
|
|
66
|
-
|
|
61
|
+
from machineconfig.utils.ve import get_ve_path_and_ipython_profile
|
|
62
|
+
_ve_root_from_file, ipy_profile = get_ve_path_and_ipython_profile(init_path=choice_file)
|
|
67
63
|
if ipy_profile is None:
|
|
68
64
|
ipy_profile = "default"
|
|
69
65
|
exe = f"uv run {with_project} ipython -i --no-banner --profile {ipy_profile} "
|
|
@@ -76,9 +72,8 @@ uv run --project {repo_root} --with marimo marimo edit --host 0.0.0.0 marimo_nb.
|
|
|
76
72
|
else:
|
|
77
73
|
raise NotImplementedError(f"File type {choice_file.suffix} not supported, in the sense that I don't know how to fire it.")
|
|
78
74
|
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
): # because debugging tools do not support choosing functions and don't interplay with fire module. So the only way to have debugging and choose function options is to import the file as a module into a new script and run the function of interest there and debug the new script.
|
|
75
|
+
if args.module or (args.debug and args.choose_function):
|
|
76
|
+
# because debugging tools do not support choosing functions and don't interplay with fire module. So the only way to have debugging and choose function options is to import the file as a module into a new script and run the function of interest there and debug the new script.
|
|
82
77
|
assert choice_file.suffix == ".py", f"File must be a python file to be imported as a module. Got {choice_file}"
|
|
83
78
|
from machineconfig.scripts.python.helpers_fire_command.file_wrangler import get_import_module_code, wrap_import_in_try_except
|
|
84
79
|
from machineconfig.utils.meta import lambda_to_python_script
|
|
@@ -92,9 +87,12 @@ uv run --project {repo_root} --with marimo marimo edit --host 0.0.0.0 marimo_nb.
|
|
|
92
87
|
in_global=True,
|
|
93
88
|
import_module=False,
|
|
94
89
|
)
|
|
90
|
+
# print(f"🧩 Preparing import code for module import:\n{import_code}")
|
|
95
91
|
code_printing = lambda_to_python_script(
|
|
96
|
-
lambda: print_code(code=import_code_robust, lexer="python", desc="import code"),
|
|
92
|
+
lambda: print_code(code=import_code_robust, lexer="python", desc="import as module code"),
|
|
93
|
+
in_global=True, import_module=False
|
|
97
94
|
)
|
|
95
|
+
print(f"🧩 Preparing import code for module import:\n{import_code}")
|
|
98
96
|
if choice_function is not None:
|
|
99
97
|
calling = f"""res = {choice_function}({("**" + str(kwargs_dict)) if kwargs_dict else ""})"""
|
|
100
98
|
else:
|
|
@@ -105,6 +103,7 @@ uv run --project {repo_root} --with marimo marimo edit --host 0.0.0.0 marimo_nb.
|
|
|
105
103
|
|
|
106
104
|
# ========================= determining basic command structure: putting together exe & choice_file & choice_function & pdb
|
|
107
105
|
if args.debug:
|
|
106
|
+
import platform
|
|
108
107
|
if platform.system() == "Windows":
|
|
109
108
|
command = f"{exe} -m ipdb {choice_file} " # pudb is not available on windows machines, use poor man's debugger instead.
|
|
110
109
|
elif platform.system() in ["Linux", "Darwin"]:
|
|
@@ -172,6 +171,7 @@ uv run --project {repo_root} --with marimo marimo edit --host 0.0.0.0 marimo_nb.
|
|
|
172
171
|
export_line = add_to_path(path_variable="PYTHONPATH", directory=str(repo_root))
|
|
173
172
|
command = export_line + "\n" + command
|
|
174
173
|
if args.loop:
|
|
174
|
+
import platform
|
|
175
175
|
if platform.system() in ["Linux", "Darwin"]:
|
|
176
176
|
command = command + "\nsleep 0.5"
|
|
177
177
|
elif platform.system() == "Windows":
|
|
@@ -213,6 +213,7 @@ def fire(
|
|
|
213
213
|
"""Main function to process fire jobs arguments."""
|
|
214
214
|
|
|
215
215
|
# Get Fire arguments from context
|
|
216
|
+
from machineconfig.scripts.python.helpers_fire_command.fire_jobs_args_helper import FireJobArgs, parse_fire_args_from_context
|
|
216
217
|
fire_args = parse_fire_args_from_context(ctx)
|
|
217
218
|
|
|
218
219
|
args = FireJobArgs(
|
|
@@ -265,4 +266,4 @@ def main():
|
|
|
265
266
|
|
|
266
267
|
|
|
267
268
|
if __name__ == "__main__":
|
|
268
|
-
|
|
269
|
+
from machineconfig.scripts.python.helpers_fire_command.fire_jobs_args_helper import FireJobArgs
|
|
@@ -6,17 +6,7 @@ Currently, the only way to work around this is to predifine the host in ~/.ssh/c
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import typer
|
|
9
|
-
from
|
|
10
|
-
from rich.console import Console
|
|
11
|
-
from rich.panel import Panel
|
|
12
|
-
|
|
13
|
-
from machineconfig.utils.ssh import SSH
|
|
14
|
-
from machineconfig.utils.path_extended import PathExtended
|
|
15
|
-
from machineconfig.scripts.python.helpers_cloud.helpers2 import ES
|
|
16
|
-
from machineconfig.utils.accessories import pprint
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
console = Console()
|
|
9
|
+
from typing import Annotated
|
|
20
10
|
|
|
21
11
|
|
|
22
12
|
def ftpx(
|
|
@@ -25,7 +15,41 @@ def ftpx(
|
|
|
25
15
|
recursive: Annotated[bool, typer.Option("--recursive", "-r", help="Send recursively.")] = False,
|
|
26
16
|
zipFirst: Annotated[bool, typer.Option("--zipFirst", "-z", help="Zip before sending.")] = False,
|
|
27
17
|
cloud: Annotated[bool, typer.Option("--cloud", "-c", help="Transfer through the cloud.")] = False,
|
|
18
|
+
overwrite_existing: Annotated[bool, typer.Option("--overwrite-existing", "-o", help="Overwrite existing files on remote when sending from local to remote.")] = False,
|
|
28
19
|
) -> None:
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
if target == "wsl" or source == "wsl":
|
|
22
|
+
from machineconfig.utils.ssh_utils.wsl import copy_when_inside_windows
|
|
23
|
+
if target == "wsl":
|
|
24
|
+
target_obj = Path(source).expanduser().absolute().relative_to(Path.home())
|
|
25
|
+
source_obj = target_obj
|
|
26
|
+
else:
|
|
27
|
+
source_obj = Path(target).expanduser().absolute().relative_to(Path.home())
|
|
28
|
+
target_obj = source_obj
|
|
29
|
+
copy_when_inside_windows(source_obj, target_obj, overwrite_existing)
|
|
30
|
+
return
|
|
31
|
+
elif source == "win" or target == "win":
|
|
32
|
+
if source == "win":
|
|
33
|
+
source_obj = Path(target).expanduser().absolute().relative_to(Path.home())
|
|
34
|
+
target_obj = source_obj
|
|
35
|
+
else:
|
|
36
|
+
target_obj = Path(source).expanduser().absolute().relative_to(Path.home())
|
|
37
|
+
source_obj = target_obj
|
|
38
|
+
from machineconfig.utils.ssh_utils.wsl import copy_when_inside_wsl
|
|
39
|
+
copy_when_inside_wsl(source_obj, target_obj, overwrite_existing)
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
from rich.console import Console
|
|
43
|
+
from rich.panel import Panel
|
|
44
|
+
|
|
45
|
+
from machineconfig.utils.ssh import SSH
|
|
46
|
+
from machineconfig.utils.path_extended import PathExtended
|
|
47
|
+
from machineconfig.scripts.python.helpers_cloud.helpers2 import ES
|
|
48
|
+
from machineconfig.utils.accessories import pprint
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
console = Console()
|
|
52
|
+
|
|
29
53
|
console.print(
|
|
30
54
|
Panel(
|
|
31
55
|
"\n".join(
|
|
@@ -185,7 +209,7 @@ def ftpx(
|
|
|
185
209
|
padding=(1, 2),
|
|
186
210
|
)
|
|
187
211
|
)
|
|
188
|
-
received_file = ssh.copy_from_here(source_path=resolved_source, target_rel2home=resolved_target, compress_with_zip=zipFirst, recursive=recursive, overwrite_existing=
|
|
212
|
+
received_file = ssh.copy_from_here(source_path=resolved_source, target_rel2home=resolved_target, compress_with_zip=zipFirst, recursive=recursive, overwrite_existing=overwrite_existing)
|
|
189
213
|
|
|
190
214
|
if source_is_remote and isinstance(received_file, PathExtended):
|
|
191
215
|
console.print(
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
import ast
|
|
3
|
+
import os
|
|
4
|
+
from typing import TypedDict
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SymbolInfo(TypedDict):
|
|
8
|
+
"""Represents a symbol (module, class, or function) in the repository."""
|
|
9
|
+
type: str
|
|
10
|
+
name: str
|
|
11
|
+
path: str
|
|
12
|
+
# line: int | None
|
|
13
|
+
# column: int | None
|
|
14
|
+
docstring: str
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _get_docstring(node: ast.AsyncFunctionDef | ast.FunctionDef | ast.ClassDef | ast.Module) -> str:
|
|
18
|
+
"""Extract docstring from an AST node."""
|
|
19
|
+
return ast.get_docstring(node) or ""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _extract_symbols(tree: ast.AST, module_path: str, source: str) -> list[SymbolInfo]:
|
|
23
|
+
"""Extract symbols from an AST tree."""
|
|
24
|
+
symbols: list[SymbolInfo] = []
|
|
25
|
+
|
|
26
|
+
for node in ast.walk(tree):
|
|
27
|
+
if isinstance(node, ast.FunctionDef | ast.AsyncFunctionDef):
|
|
28
|
+
symbol: SymbolInfo = {
|
|
29
|
+
"type": "function",
|
|
30
|
+
"name": node.name,
|
|
31
|
+
"path": f"{module_path}.{node.name}",
|
|
32
|
+
"docstring": _get_docstring(node),
|
|
33
|
+
}
|
|
34
|
+
symbols.append(symbol)
|
|
35
|
+
elif isinstance(node, ast.ClassDef):
|
|
36
|
+
symbol: SymbolInfo = {
|
|
37
|
+
"type": "class",
|
|
38
|
+
"name": node.name,
|
|
39
|
+
"path": f"{module_path}.{node.name}",
|
|
40
|
+
"docstring": _get_docstring(node),
|
|
41
|
+
}
|
|
42
|
+
symbols.append(symbol)
|
|
43
|
+
|
|
44
|
+
return symbols
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_repo_symbols(repo_path: str) -> list[SymbolInfo]:
|
|
48
|
+
skip_dirs = {'.venv', 'venv', '__pycache__', '.mypy_cache', '.pytest_cache', '.git'}
|
|
49
|
+
results: list[SymbolInfo] = []
|
|
50
|
+
counter: int = 0
|
|
51
|
+
for root, dirs, files in os.walk(repo_path):
|
|
52
|
+
dirs[:] = [d for d in dirs if d not in skip_dirs and not d.startswith('.')]
|
|
53
|
+
for file in files:
|
|
54
|
+
if not file.endswith(".py"):
|
|
55
|
+
continue
|
|
56
|
+
file_path = os.path.join(root, file)
|
|
57
|
+
module_path = (
|
|
58
|
+
os.path.relpath(file_path, repo_path)
|
|
59
|
+
.replace(os.sep, ".")
|
|
60
|
+
.removesuffix(".py")
|
|
61
|
+
)
|
|
62
|
+
try:
|
|
63
|
+
if counter % 100 == 0: print(f"🔍 Parsing {counter}: {file_path}...")
|
|
64
|
+
with open(file_path, encoding="utf-8") as f:
|
|
65
|
+
source = f.read()
|
|
66
|
+
tree = ast.parse(source, filename=file_path)
|
|
67
|
+
symbols = _extract_symbols(tree, module_path, source)
|
|
68
|
+
results.extend(symbols)
|
|
69
|
+
except Exception as e:
|
|
70
|
+
print(f"⚠️ Error parsing {file_path}: {e}")
|
|
71
|
+
continue
|
|
72
|
+
counter += 1
|
|
73
|
+
|
|
74
|
+
return results
|