Skip to content

Conversation

pgierz
Copy link

@pgierz pgierz commented Aug 27, 2025

closes #96

This automatically detects the gitlab host you used and injects it into the provided snakemake module.

Summary by CodeRabbit

  • New Features
    • Added support for specifying a custom host during deployment.
    • Improved compatibility with self-hosted GitHub and GitLab instances when generating source declarations.
    • Maintains backward compatibility: if no host is provided, behavior remains unchanged.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 27, 2025

📝 Walkthrough

Walkthrough

Introduces an optional host parameter across deployment and provider APIs. WorkflowDeployer now stores host and passes it to provider.get_source_file_declaration. Providers (Github, Gitlab, Local) accept host; Gitlab derives host from non-gitlab.com URLs when not provided. The top-level deploy() signature includes host but may not pass it into WorkflowDeployer.

Changes

Cohort / File(s) Summary
Public API: host parameter
snakedeploy/deploy.py
Adds host: Optional[str] to WorkflowDeployer.init and deploy() signatures; stores self.host; passes host to provider when rendering module declaration. Note: deploy() currently doesn’t propagate host to WorkflowDeployer instance per summary.
Providers: host-aware source declaration
snakedeploy/providers.py
Adds host: Optional[str] to Provider.get_source_file_declaration across Provider, Local, Github, Gitlab. Gitlab uses host if provided or derives from URL when non-gitlab.com; Github optionally includes host; Local ignores host in declaration. Typing/import cleanups; PROVIDERS list unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as CLI / deploy()
  participant WD as WorkflowDeployer
  participant Prov as Provider (Gitlab/Github/Local)
  participant FS as Filesystem

  User->>CLI: deploy(source_url, ..., host?)
  CLI->>WD: new WorkflowDeployer(..., host?)  %% If propagated
  note over WD: Stores self.host
  WD->>Prov: get_source_file_declaration(path, tag, branch, host=self.host)
  alt Provider = Gitlab
    note right of Prov: If host is None and URL not gitlab.com,<br/>derive host from URL
  end
  Prov-->>WD: source-file declaration string
  WD->>FS: Write Snakefile with module declaration
  FS-->>User: Snakefile created/updated
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Assessment against linked issues

Objective Addressed Explanation
Support host in GitLab module declaration so non-gitlab.com URLs include host (e.g., gitlab.awi.de) [#96]

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Add optional host handling to Github.get_source_file_declaration (snakedeploy/providers.py) Issue #96 concerns GitLab hosts only; extending Github is not required by the stated objective.
Add host parameter to Local.get_source_file_declaration (snakedeploy/providers.py) Local provider host handling is unrelated to GitLab host support requested in #96.
Extend public deploy() API to include host (snakedeploy/deploy.py) Changing the top-level API is not explicitly required to solve GitLab host declaration; internal derivation in GitLab provider would suffice.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
snakedeploy/deploy.py (1)

280-283: Bug: host is not forwarded to WorkflowDeployer.

deploy() accepts host but does not pass it to WorkflowDeployer, so self.host is always None. This breaks auto-injection for GitLab hosts when using deploy().

Apply this diff:

-    with WorkflowDeployer(
-        source=source_url, dest=dest_path, tag=tag, branch=branch, force=force
-    ) as sd:
+    with WorkflowDeployer(
+        source=source_url,
+        dest=dest_path,
+        tag=tag,
+        branch=branch,
+        force=force,
+        host=host,
+    ) as sd:
         sd.deploy(name=name)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0e78b and e856589.

📒 Files selected for processing (2)
  • snakedeploy/deploy.py (4 hunks)
  • snakedeploy/providers.py (5 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

⚙️ CodeRabbit configuration file

**/*.py: Do not try to improve formatting.
Do not suggest type annotations for functions that are defined inside of functions or methods.
Do not suggest type annotation of the self argument of methods.
Do not suggest type annotation of the cls argument of classmethods.
Do not suggest return type annotation if a function or method does not contain a return statement.

Files:

  • snakedeploy/deploy.py
  • snakedeploy/providers.py
🧬 Code graph analysis (1)
snakedeploy/providers.py (1)
snakedeploy/exceptions.py (1)
  • UserError (43-44)
🔇 Additional comments (8)
snakedeploy/providers.py (4)

1-8: Imports update looks good.

Optional was added and imports reorganized appropriately.


36-38: Abstract method signatures: OK.

Adding explicit annotations and placeholders is fine.

Also applies to: 40-42, 44-46, 48-50


82-84: Local.get_source_file_declaration: OK (host intentionally unused).

Signature compatibility maintained; ignoring host for local sources is reasonable.


116-118: Confirm intent: host is ignored for Github provider.

If GitHub Enterprise support is desired, consider propagating host here (only if Snakemake’s github() accepts it); otherwise, leaving it unused is fine for this PR’s GitLab focus.

snakedeploy/deploy.py (4)

24-25: Add host to WorkflowDeployer: OK.

Constructor signature change looks good.


33-33: Store host on instance: OK.

Passed through for later rendering.


231-233: Pass host to provider declaration: OK.

Host is now threaded into the Snakefile template call.


258-259: Top-level deploy() accepts host: OK.

Public API extended as per PR objective.

Comment on lines +130 to +142
def get_source_file_declaration(
self, path: str, tag: str, branch: str, host: Optional[str] = None
):
owner_repo = "/".join(self.source_url.split("/")[-2:])
url_host = self.source_url.split("/")[2]
if host is None and url_host != "gitlab.com":
host = url_host
if not (tag or branch):
raise UserError("Either tag or branch has to be specified for deployment.")
ref_arg = f'tag="{tag}"' if tag is not None else f'branch="{branch}"'
host_arg = f'host="{host}"' if host is not None else ""
return f'{self.name}("{owner_repo}", path="{path}", {ref_arg}, {host_arg})'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix GitLab namespace parsing and avoid dangling comma in call.

  • owner_repo drops parent groups for nested namespaces (e.g., group/subgroup/repo).
  • Building the call with an empty host_arg yields a trailing comma in the argument list.

Proposed fix:

  • Use the full path after the host for owner_repo.
  • Build args dynamically to avoid the dangling comma.

Apply this diff:

 def get_source_file_declaration(
     self, path: str, tag: str, branch: str, host: Optional[str] = None
 ):
-    owner_repo = "/".join(self.source_url.split("/")[-2:])
-    url_host = self.source_url.split("/")[2]
+    # Use full namespace path (supports nested groups)
+    owner_repo = "/".join(self.source_url.split("/")[3:])
+    url_host = self.source_url.split("/")[2]
     if host is None and url_host != "gitlab.com":
         host = url_host
     if not (tag or branch):
         raise UserError("Either tag or branch has to be specified for deployment.")
     ref_arg = f'tag="{tag}"' if tag is not None else f'branch="{branch}"'
-    host_arg = f'host="{host}"' if host is not None else ""
-    return f'{self.name}("{owner_repo}", path="{path}", {ref_arg}, {host_arg})'
+    args = [f'"{owner_repo}"', f'path="{path}"', ref_arg]
+    if host is not None:
+        args.append(f'host="{host}"')
+    return f'{self.name}({", ".join(args)})'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def get_source_file_declaration(
self, path: str, tag: str, branch: str, host: Optional[str] = None
):
owner_repo = "/".join(self.source_url.split("/")[-2:])
url_host = self.source_url.split("/")[2]
if host is None and url_host != "gitlab.com":
host = url_host
if not (tag or branch):
raise UserError("Either tag or branch has to be specified for deployment.")
ref_arg = f'tag="{tag}"' if tag is not None else f'branch="{branch}"'
host_arg = f'host="{host}"' if host is not None else ""
return f'{self.name}("{owner_repo}", path="{path}", {ref_arg}, {host_arg})'
def get_source_file_declaration(
self, path: str, tag: str, branch: str, host: Optional[str] = None
):
# Use full namespace path (supports nested groups)
owner_repo = "/".join(self.source_url.split("/")[3:])
url_host = self.source_url.split("/")[2]
if host is None and url_host != "gitlab.com":
host = url_host
if not (tag or branch):
raise UserError("Either tag or branch has to be specified for deployment.")
ref_arg = f'tag="{tag}"' if tag is not None else f'branch="{branch}"'
- host_arg = f'host="{host}"' if host is not None else ""
args = [f'"{owner_repo}"', f'path="{path}"', ref_arg]
if host is not None:
args.append(f'host="{host}"')
return f'{self.name}({", ".join(args)})'
🤖 Prompt for AI Agents
In snakedeploy/providers.py around lines 130 to 142, owner_repo currently uses
only the last two path segments which loses parent groups for nested GitLab
namespaces and host handling can produce an empty host_arg that leaves a
dangling comma in the returned call string; to fix, derive owner_repo as the
full path portion after the host (i.e., join all segments after the domain),
determine url_host from the netloc/second segment as you already do, build a
list of argument strings starting with the required '"{owner_repo}"' and
'path="{path}"', add the ref argument as tag or branch depending on which is
set, and only append a host="..." argument if host is not None, then return the
call by joining the args with ", " so no trailing comma appears.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Gitlab Hosts

1 participant