refactor(mono): convert third-party and buckal-bundles init to script#1876
Conversation
Signed-off-by: MYUU <1405758738@qq.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b76bc38a18
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| req = urllib.request.Request(url, data=req_data, headers=headers, method=method) | ||
|
|
||
| try: | ||
| with urllib.request.urlopen(req, timeout=10) as response: | ||
| resp_body = response.read().decode("utf-8") | ||
| if response.status >= 200 and response.status < 300: | ||
| return json.loads(resp_body) if resp_body else {} |
There was a problem hiding this comment.
Avoid proxying Mega API calls by default
The new api_request path uses urllib.request.urlopen with default proxy handling, which respects HTTP_PROXY/HTTPS_PROXY. In environments where those are set (common in CI), calls to a local or internal --base-url can be routed through a proxy and fail unless NO_PROXY is configured. The previous in-server implementation explicitly disabled proxies (no_proxy()), so this is a regression for users running against http://127.0.0.1:8000 or other internal hosts. Consider disabling proxies for these API calls or honoring NO_PROXY explicitly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR refactors the automatic initialization of third-party and Buckal bundles from in-process server startup code into a standalone Python script that can be run manually or in CI. It decouples repo initialization workflows (Buckal Bundles and Libra imports) from the mono HTTP server lifecycle.
Changes:
- Add
scripts/init_mega/init_mega.py, a Python CLI that waits for a Mega server, runs the Buckal Bundles import via Git + Mega APIs, and runs the Libra Buck2 deps import via the existing in-repo script. - Document the new script’s behavior, requirements, arguments, and usage in
scripts/init_mega/README.md. - Remove the Rust
init_tasksmodule and its invocation from the HTTP server so initialization workflows are no longer triggered automatically on server startup.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
scripts/init_mega/init_mega.py |
New standalone initialization script implementing the Buckal Bundles and Libra workflows previously embedded in the Rust server. |
scripts/init_mega/README.md |
Documentation of the new init script, its parameters, behavior, and usage examples. |
mono/src/server/mod.rs |
Removes the init_tasks module export now that initialization is handled externally. |
mono/src/server/init_tasks.rs |
Deletes the old Rust-based initialization workflows that ran inside the server process. |
mono/src/server/http_server.rs |
Removes the spawn of run_initialization_tasks, fully decoupling HTTP startup from init workflows. |
|
|
||
| except Exception as e: | ||
| print(f"\nInitialization failed: {e}") | ||
| exit(1) |
There was a problem hiding this comment.
Using exit(1) in a script relies on the site module installing this helper into builtins, which is not guaranteed in all interpreter/embedder configurations; the more robust and conventional pattern is to import sys and call sys.exit(1) instead.
| def api_request(method, url, data=None, headers=None): | ||
| """Performs an HTTP API request.""" | ||
| if headers is None: | ||
| headers = {} | ||
|
|
||
| if "accept" not in headers: | ||
| headers["accept"] = "application/json" | ||
|
|
||
| req_data = None | ||
| if data is not None: | ||
| req_data = json.dumps(data).encode("utf-8") | ||
| if "Content-Type" not in headers: | ||
| headers["Content-Type"] = "application/json" | ||
|
|
||
| req = urllib.request.Request(url, data=req_data, headers=headers, method=method) | ||
|
|
||
| try: | ||
| with urllib.request.urlopen(req, timeout=10) as response: | ||
| resp_body = response.read().decode("utf-8") | ||
| if response.status >= 200 and response.status < 300: | ||
| return json.loads(resp_body) if resp_body else {} | ||
| else: | ||
| raise RuntimeError(f"API request failed with status {response.status}: {resp_body}") | ||
| except Exception as e: | ||
| raise RuntimeError(f"API request to {url} failed: {e}") |
There was a problem hiding this comment.
The HTTP helper here uses urllib's default opener, which will respect environment proxy settings (HTTP(S)_PROXY, etc.), whereas the previous Rust implementation built a reqwest client with no_proxy(). In environments with a global proxy configured, calls to the internal Mega server (status, CL list, merge) could now be routed through a proxy and fail or leak internal traffic; consider explicitly disabling proxies for these requests or making proxy behavior configurable to preserve the prior semantics.
|
|
||
| while time.time() - start_time < timeout: | ||
| try: | ||
| resp = api_request("GET", status_url) |
There was a problem hiding this comment.
Variable resp is not used.
| resp = api_request("GET", status_url) | |
| api_request("GET", status_url) |
|
|
||
| import argparse | ||
| import json | ||
| import os |
There was a problem hiding this comment.
Import of 'os' is not used.
…gitmono-dev#1876) Signed-off-by: MYUU <1405758738@qq.com>
…gitmono-dev#1876) Signed-off-by: MYUU <1405758738@qq.com>
…gitmono-dev#1876) Signed-off-by: MYUU <1405758738@qq.com>
…gitmono-dev#1876) Signed-off-by: MYUU <1405758738@qq.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com>
…d WebSocket (#1909) * refactor: some modules (#4) * feat: add refactor orion module for migration Signed-off-by: Wangyan <topshihun@foxmail.com> * fix: add CL for build Signed-off-by: Wangyan <topshihun@foxmail.com> * refactor: some modules Signed-off-by: Wangyan <topshihun@foxmail.com> --------- Signed-off-by: Wangyan <topshihun@foxmail.com> Signed-off-by: Aid_C <57825561+AidCheng@users.noreply.github.com> Co-authored-by: Aid_C <57825561+AidCheng@users.noreply.github.com> * [orion]REFACTOR: Integrate generic jupiter model with refactored orion structure Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * fix: enforce mount_path semantics and stabilize builds (#1836) * fix: enforce mount_path semantics and stabilize builds Consolidate mount_path handling with buck2 prechecks and fix BuildDTO repo handling to avoid moves. Signed-off-by: jerry609 <1772030600@qq.com> style: format code with cargo fmt Signed-off-by: jerry609 <1772030600@qq.com> chore(orion): remove unused mount helpers Signed-off-by: jerry609 <1772030600@qq.com> fix(orion): retry buck2 targets once on failure Signed-off-by: jerry609 <1772030600@qq.com> fix(orion): remount and retry target discovery on failure Signed-off-by: jerry609 <1772030600@qq.com> style(orion): format buck_controller after retry changes Signed-off-by: jerry609 <1772030600@qq.com> fix(orion): annotate changes type for retry path Signed-off-by: jerry609 <1772030600@qq.com> fix(orion): appease clippy for mount guards Signed-off-by: jerry609 <1772030600@qq.com> test(common): avoid clippy field reassignment lint Signed-off-by: jerry609 <1772030600@qq.com> * test(ceres): fix clippy lints in tests Signed-off-by: jerry609 <1772030600@qq.com> --------- Signed-off-by: jerry609 <1772030600@qq.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * Feature/comment reanchor (#1874) * refactor(code_review): add anchor and position to locat code thread * feat: add reanchor thread function * fix: seaORM repeated * fix: rebase error * fix: lcs_len error * fix: fix CR problems * fix: error Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * feat(theme): Complete theme color migration for multiple modules (#1875) * feat(theme): Complete theme color system migration for CL, Issue, Queue, OrionClient, and Settings modules * feat(theme): Complete theme color system migration for CL, Issue, Queue, OrionClient, and Settings modules * feat(theme): Complete theme color system migration for CL, Issue, Queue, OrionClient, and Settings modules * feat(theme): Complete theme color system migration for CL, Issue, Queue, OrionClient, and Settings modules Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * refactor(mono): convert third-party and buckal-bundles init to script (#1876) Signed-off-by: MYUU <1405758738@qq.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * chore: move log models under buck2 types (#1878) Signed-off-by: lvy010 <17338770572@163.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * test(mono): add multi-user support and files-list API (#1881) * test(mono): Add CL merge and update-branch integration test Signed-off-by: miliu2cc <miliu2cc@gmail.com> * test(mono): Add CL merge and update-branch integration test Signed-off-by: miliu2cc <miliu2cc@gmail.com> * test(mono): add multi-user support and files-list API Signed-off-by: miliu2cc <miliu2cc@gmail.com> * test(mono): add multi-user support and files-list API Signed-off-by: miliu2cc <miliu2cc@gmail.com> --------- Signed-off-by: miliu2cc <miliu2cc@gmail.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * fix(script):cleanup per-repo .git after processing (#1884) Signed-off-by: MYUU <1405758738@qq.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * feat: implement build trigger system (#1880) * feat: implement build trigger system Signed-off-by: allure <1550220889@qq.com> * feat: refactor build trigger system and fix error Signed-off-by: allure <1550220889@qq.com> --------- Signed-off-by: allure <1550220889@qq.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * fix(orion): skip incompatible targets for buck2 builds (#1885) Signed-off-by: jerry609 <1772030600@qq.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * fixed(cl): update UI for checks log section (#1887) Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * refactor: some modules (#4) * feat: add refactor orion module for migration Signed-off-by: Wangyan <topshihun@foxmail.com> * fix: add CL for build Signed-off-by: Wangyan <topshihun@foxmail.com> * refactor: some modules Signed-off-by: Wangyan <topshihun@foxmail.com> --------- Signed-off-by: Wangyan <topshihun@foxmail.com> Signed-off-by: Aid_C <57825561+AidCheng@users.noreply.github.com> Co-authored-by: Aid_C <57825561+AidCheng@users.noreply.github.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * [buck2]REFACTOR: Integrate orion and orion server with generic api and model interface Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * FIX: use correct ProjectRelativePath crate Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * UPDATE: cargo fmt Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * [orion] Replace worker-server commun with WS msg Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * [orion]FIX: update branch and fix conflicts * [Orion]FIX: workflow error Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * [orion]UPDATE: fix based on copilot suggestions Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * cargo fmt Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * UPDATE: temporary allow unused started at in build info Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * FIX: remove unused import Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * fmt Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> * [jupiter]REMOVE: duplicate migration Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Aid_C <57825561+AidCheng@users.noreply.github.com> * [jupiter]FIX: temporary remove task.rs Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> --------- Signed-off-by: Wangyan <topshihun@foxmail.com> Signed-off-by: Aid_C <57825561+AidCheng@users.noreply.github.com> Signed-off-by: AidCheng <cn.aiden.cheng@gmail.com> Signed-off-by: jerry609 <1772030600@qq.com> Signed-off-by: MYUU <1405758738@qq.com> Signed-off-by: lvy010 <17338770572@163.com> Signed-off-by: miliu2cc <miliu2cc@gmail.com> Signed-off-by: allure <1550220889@qq.com> Co-authored-by: TOP <89700178+topshihun@users.noreply.github.com> Co-authored-by: Jerry Zhang <1772030600@qq.com> Co-authored-by: TianYi <2739022972@qq.com> Co-authored-by: zhaokang <zhaokang.r2cn@isrc.iscas.ac.cn> Co-authored-by: MYUU <52773565+zhoujiaqi30@users.noreply.github.com> Co-authored-by: lvy010 <17338770572@163.com> Co-authored-by: miliu2cc <98928567+miliu2cc@users.noreply.github.com> Co-authored-by: Yao <1550220889@qq.com> Co-authored-by: zyd123-cmd <yingdong.r2cn@isrc.iscas.ac.cn> Co-authored-by: Tianxing Ye <benjamin.747@outlook.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
将自动化引入third-party和buckal-bundles流程改为一个单独的脚本