You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "michael-s-molina (via GitHub)" <gi...@apache.org> on 2025/11/27 17:00:32 UTC

[PR] chore: Adds non-interactive mode to `superset-extensions init` command [superset]

michael-s-molina opened a new pull request, #36308:
URL: https://github.com/apache/superset/pull/36308

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   Adds non-interactive mode to `superset-extensions init` command to enable AI assistants and automation scripts to create extensions without interactive prompts.
   
   **New CLI options:**
   - `--id` - Extension ID
   - `--name` - Extension display name
   - `--version` - Initial version (defaults to 0.1.0)
   - `--license` - License (defaults to Apache-2.0)
   - `--frontend/--no-frontend` - Include frontend
   - `--backend/--no-backend` - Include backend
   
   **Usage:**
   ```bash
   superset-extensions init --id hello_world --name "Hello World" --frontend --backend
   ```
   
   Backward compatible - interactive mode still works when options are not provided.
   
   ### TESTING INSTRUCTIONS
   Use AI to run `superset-extensions init`
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Adds non-interactive mode to `superset-extensions init` command [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina merged PR #36308:
URL: https://github.com/apache/superset/pull/36308


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Adds non-interactive mode to `superset-extensions init` command [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #36308:
URL: https://github.com/apache/superset/pull/36308#discussion_r2569561269


##########
superset-extensions-cli/src/superset_extensions_cli/cli.py:
##########
@@ -404,19 +404,28 @@ def backend_watcher() -> None:
 
 
 @app.command()
-def init() -> None:
-    id_ = click.prompt("Extension ID (unique identifier, alphanumeric only)", type=str)
+@click.option("--id", "id_opt", default=None, help="Extension ID (alphanumeric and underscores only)")
+@click.option("--name", "name_opt", default=None, help="Extension display name")
+@click.option("--version", "version_opt", default=None, help="Initial version (default: 0.1.0)")
+@click.option("--license", "license_opt", default=None, help="License (default: Apache-2.0)")
+@click.option("--frontend/--no-frontend", "frontend_opt", default=None, help="Include frontend")
+@click.option("--backend/--no-backend", "backend_opt", default=None, help="Include backend")
+def init(id_opt: str | None, name_opt: str | None, version_opt: str | None, license_opt: str | None, frontend_opt: bool | None, backend_opt: bool | None) -> None:
+    # Check if running in non-interactive mode (required options provided)
+    non_interactive = id_opt is not None and name_opt is not None and frontend_opt is not None and backend_opt is not None
+
+    id_ = id_opt or click.prompt("Extension ID (unique identifier, alphanumeric only)", type=str)
     if not re.match(r"^[a-zA-Z0-9_]+$", id_):
         click.secho(
             "❌ ID must be alphanumeric (letters, digits, underscore).", fg="red"
         )
         sys.exit(1)
 
-    name = click.prompt("Extension name (human-readable display name)", type=str)
-    version = click.prompt("Initial version", default="0.1.0")
-    license = click.prompt("License", default="Apache-2.0")
-    include_frontend = click.confirm("Include frontend?", default=True)
-    include_backend = click.confirm("Include backend?", default=True)
+    name = name_opt or click.prompt("Extension name (human-readable display name)", type=str)
+    version = version_opt if version_opt is not None else ("0.1.0" if non_interactive else click.prompt("Initial version", default="0.1.0"))
+    license = license_opt if license_opt is not None else ("Apache-2.0" if non_interactive else click.prompt("License", default="Apache-2.0"))
+    include_frontend = frontend_opt if frontend_opt is not None else click.confirm("Include frontend?", default=True)
+    include_backend = backend_opt if backend_opt is not None else click.confirm("Include backend?", default=True)

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Variable shadows Python builtin</b></div>
   <div id="fix">
   
   Variable `license` shadows the Python builtin `license` (A001). Rename to `license_str` or similar to avoid shadowing.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       license_str = license_opt if license_opt is not None else ("Apache-2.0" if non_interactive else click.prompt("License", default="Apache-2.0"))
       include_frontend = frontend_opt if frontend_opt is not None else click.confirm("Include frontend?", default=True)
       include_backend = backend_opt if backend_opt is not None else click.confirm("Include backend?", default=True)
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36308#issuecomment-3586798611>#39fbc6</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Adds non-interactive mode to `superset-extensions init` command [superset]

Posted by "villebro (via GitHub)" <gi...@apache.org>.
villebro commented on code in PR #36308:
URL: https://github.com/apache/superset/pull/36308#discussion_r2577949168


##########
superset-extensions-cli/src/superset_extensions_cli/cli.py:
##########
@@ -404,19 +404,81 @@ def backend_watcher() -> None:
 
 
 @app.command()
-def init() -> None:
-    id_ = click.prompt("Extension ID (unique identifier, alphanumeric only)", type=str)
+@click.option(
+    "--id",
+    "id_opt",
+    default=None,
+    help="Extension ID (alphanumeric and underscores only)",
+)
+@click.option("--name", "name_opt", default=None, help="Extension display name")
+@click.option(
+    "--version", "version_opt", default=None, help="Initial version (default: 0.1.0)"
+)
+@click.option(
+    "--license", "license_opt", default=None, help="License (default: Apache-2.0)"
+)
+@click.option(
+    "--frontend/--no-frontend", "frontend_opt", default=None, help="Include frontend"
+)
+@click.option(
+    "--backend/--no-backend", "backend_opt", default=None, help="Include backend"
+)
+def init(
+    id_opt: str | None,
+    name_opt: str | None,
+    version_opt: str | None,
+    license_opt: str | None,
+    frontend_opt: bool | None,
+    backend_opt: bool | None,
+) -> None:
+    # Check if running in non-interactive mode (required options provided)
+    non_interactive = (
+        id_opt is not None
+        and name_opt is not None
+        and frontend_opt is not None
+        and backend_opt is not None
+    )

Review Comment:
   Instead of interactive vs non-interactive, could we just skip asking the options that are provided in the CLI call, and prompt for the ones that weren't provided up front? I.e. always doing `xyz = xyz_opt or click.prompt("Give me xyz", type=str)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Adds non-interactive mode to `superset-extensions init` command [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #36308:
URL: https://github.com/apache/superset/pull/36308#discussion_r2578497423


##########
superset-extensions-cli/src/superset_extensions_cli/cli.py:
##########
@@ -404,19 +404,81 @@ def backend_watcher() -> None:
 
 
 @app.command()
-def init() -> None:
-    id_ = click.prompt("Extension ID (unique identifier, alphanumeric only)", type=str)
+@click.option(
+    "--id",
+    "id_opt",
+    default=None,
+    help="Extension ID (alphanumeric and underscores only)",
+)
+@click.option("--name", "name_opt", default=None, help="Extension display name")
+@click.option(
+    "--version", "version_opt", default=None, help="Initial version (default: 0.1.0)"
+)
+@click.option(
+    "--license", "license_opt", default=None, help="License (default: Apache-2.0)"
+)
+@click.option(
+    "--frontend/--no-frontend", "frontend_opt", default=None, help="Include frontend"
+)
+@click.option(
+    "--backend/--no-backend", "backend_opt", default=None, help="Include backend"
+)
+def init(
+    id_opt: str | None,
+    name_opt: str | None,
+    version_opt: str | None,
+    license_opt: str | None,
+    frontend_opt: bool | None,
+    backend_opt: bool | None,
+) -> None:
+    # Check if running in non-interactive mode (required options provided)
+    non_interactive = (
+        id_opt is not None
+        and name_opt is not None
+        and frontend_opt is not None
+        and backend_opt is not None
+    )

Review Comment:
   Great suggestion. Done!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Adds non-interactive mode to `superset-extensions init` command [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #36308:
URL: https://github.com/apache/superset/pull/36308#issuecomment-3586798611

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org