-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added functionality to latch test-data upload #194
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -506,6 +506,11 @@ def test_data(ctx): | |
|
||
@test_data.command("upload") | ||
@click.argument("src_path", nargs=1, type=click.Path(exists=True)) | ||
@click.option( | ||
"--s3_path", | ||
default = None, | ||
type=str, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make this optional as well (see my other comment) |
||
help=("Destination folder path to write to on s3 (omit s3 Bucket prefix).")) | ||
@click.option( | ||
"--dont-confirm-overwrite", | ||
"-d", | ||
|
@@ -514,13 +519,13 @@ def test_data(ctx): | |
type=bool, | ||
help=("Automatically overwrite any files without asking for confirmation."), | ||
) | ||
def test_data_upload(src_path: str, dont_confirm_overwrite: bool): | ||
def test_data_upload(src_path: str, s3_path: str, dont_confirm_overwrite: bool): | ||
"""Upload test data object.""" | ||
|
||
from latch_cli.services.test_data.upload import upload | ||
|
||
try: | ||
s3_url = upload(src_path, dont_confirm_overwrite) | ||
s3_url = upload(src_path, s3_path, dont_confirm_overwrite) | ||
click.secho(f"Successfully uploaded to {s3_url}", fg="green") | ||
except Exception as e: | ||
CrashReporter.report() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,14 +5,15 @@ | |||||
import boto3 | ||||||
import botocore | ||||||
import click | ||||||
import os | ||||||
|
||||||
from latch_cli.services.test_data.utils import _retrieve_creds | ||||||
from latch_cli.utils import account_id_from_token, retrieve_or_login | ||||||
|
||||||
BUCKET = "latch-public" | ||||||
|
||||||
|
||||||
def upload(src_path: str, dont_confirm_overwrite: bool = True) -> str: | ||||||
def upload(src_path: str, s3_path: str = None, dont_confirm_overwrite: bool = True) -> str: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
using the |
||||||
"""Uploads a local file/folder to a managed bucket. | ||||||
|
||||||
Args: | ||||||
|
@@ -39,7 +40,10 @@ def upload(src_path: str, dont_confirm_overwrite: bool = True) -> str: | |||||
if account_id is None or account_id == "": | ||||||
account_id = account_id_from_token(retrieve_or_login()) | ||||||
|
||||||
allowed_key = str((Path("test-data") / account_id).joinpath(src_path)) | ||||||
if s3_path is None: | ||||||
allowed_key = str((Path("test-data") / account_id).joinpath(src_path)) | ||||||
else: | ||||||
allowed_key = str((Path("test-data") / account_id).joinpath(s3_path)) | ||||||
|
||||||
upload_helper( | ||||||
Path(src_path).resolve(), | ||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kebab-case for cli options