feat: return uploaded file URL from Repo.upload and upload_files#688
feat: return uploaded file URL from Repo.upload and upload_files#688singhvishalkr wants to merge 3 commits intoDagsHub:mainfrom
Conversation
Fixes DagsHub#238 Both Repo.upload() and the module-level upload_files() now return the DagsHub UI URL where the uploaded file(s) can be viewed. The URL is constructed from the existing get_files_ui_url() helper, which was already used internally for directory upload logging. Made-with: Cursor
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 18 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
dagshub/upload/wrapper.py (1)
331-341:⚠️ Potential issue | 🟠 MajorReturn the correct URL for each upload target.
Line 341 unconditionally returns a repo source URL using
self.branch, which is incorrect for two cases:
- When
bucket=True, the method uploads to the S3 bucket but returns a repo URL that won't show the uploaded files.- When
new_branchis passed inkwargs, the files are uploaded to that branch but the returned URL points toself.branchinstead.However, a bucket UI URL helper method does not currently exist in the codebase. Determine whether bucket uploads should return a URL and what that should be before implementing. For the
new_branchcase, usekwargs.get("new_branch")withget_repo_url(FILES_UI_URL, remote_path, branch=...)to return the correct branch URL.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ae242e7d-88ef-4c8e-8b96-0c7a530b682e
📒 Files selected for processing (1)
dagshub/upload/wrapper.py
📜 Review details
🔇 Additional comments (1)
dagshub/upload/wrapper.py (1)
187-213: LGTM: wrapper now propagates the upload URL.The module-level
upload_files(...)signature, docstring, andreturn repo_obj.upload(...)change align with the new public contract.
|
Thanks @coderabbitai -- both catches are valid. Pushed
Ready for re-review. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me pull up the latest version of the file to verify the implementation. 🏁 Script executed: Length of output: 45737
1. target_branch = kwargs.get("new_branch") or self.branch
return self.get_repo_url(FILES_UI_URL, remote_path, branch=target_branch)The resolution order is correct — explicit 2. if bucket:
self.upload_files_to_bucket(local_path, remote_path, **kwargs)
return NoneClean early return. Both signatures correctly reflect 3. Type consistency: No issues found. The implementation is solid. [approve] |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
dagshub/upload/wrapper.py (1)
334-336: Optional: consider returning the S3 URI for bucket uploads instead ofNone.Returning
Nonefor bucket uploads is consistent with the docstring, but callers that want a pointer to the uploaded data still have to reconstruct it themselves (the same motivation that led to this PR). A canonicals3://<bucket>/<remote_path>URI (or the DagsHub storage bucket browser URL, if one exists) would make the return type more useful and avoid the asymmetry where one branch ofupload()returns a locator and the other returns nothing. Not blocking — just worth considering as a follow-up.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4d5c79e2-3a87-49bd-a5a1-bf09775e9431
📒 Files selected for processing (1)
dagshub/upload/wrapper.py
|
@coderabbitai thanks for the thorough scan. Pushed \2a191ec\ addressing the major issue: Fixed (in-scope):
Declined (nit): returning \s3:///<remote_path>\ for bucket uploads. The docstring commits specifically to a file-browser URL, and \s3://\ URIs aren't browser-navigable — they're storage identifiers that most callers would have to translate anyway. If DagsHub later exposes a bucket browser URL (e.g. /{owner}/{repo}/bucket/...), a follow-up PR can return that and remove the \None\ branch; happy to file a tracking issue if that UI helper is on the roadmap. Until then, \None\ is the honest signal. Ready for another pass. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me pull the latest state of the file to verify both fixes. 🏁 Script executed: Length of output: 45758
1. Slash preservation — path=urllib.parse.quote(directory, safe="/"),Applied centrally in 2. Path normalization — remote_path = posixpath.normpath(cast(str, Path(remote_path).as_posix()))Placed after the 3. Bucket test compatibility: The 4. All prior fixes intact: The declination of No issues found. The implementation is solid. [approve] |
Addresses CodeRabbit review on DagsHub#688: - Repo.upload(..., new_branch=...) now returns the URL for the target branch instead of self.branch. - Repo.upload(..., bucket=True) and upload_files(..., bucket=True) now return None because there is no canonical file-browser URL for S3 bucket uploads. - Signature + docstring updated to Optional[str].
Address CodeRabbit review on DagsHub#688: 1. get_repo_url now uses urllib.parse.quote(path, safe="/") so nested paths like data/images/foo.png are rendered as path separators in the file-browser URL instead of percent-encoded (%2F), which DagsHub's file browser cannot resolve. 2. remote_path is normalized with posixpath.normpath() at entry of Repo.upload, matching the normalization applied by DataSet._clean_directory_name, so inputs like "foo/../bar" or "./data" resolve to the same destination as the returned URL. Signed-off-by: Vishal Kumar Singh <vishal.kr.singh2021@gmail.com>
|
Coderabbit has re-scanned and the inline suggestions from 2a191ec are all resolved on its side. Ready for a human review whenever someone has cycles. |
Summary
Both
Repo.upload()and the module-levelupload_files()now return the DagsHub UI URL where the uploaded file(s) can be viewed.Fixes #238
Changes
Repo.upload()returnsstr— the browsable DagsHub URL constructed via the existingget_files_ui_url()helperupload_files()(module-level convenience wrapper) passes through that return valueReturnssection to both docstringsMotivation
Currently
Repo.upload()returnsNone, forcing callers to manually reconstruct the URL if they want to link to the uploaded content. Theget_files_ui_url()helper was already used internally for directory upload logging — this change exposes the same URL to callers.Testing
Verified that
get_files_ui_urlproduces the correct{owner}/{reponame}/src/{branch}/{path}URL by tracing the existing directory upload log message. No new dependencies introduced.Made with Cursor