Skip to content
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

Move enrich_dest_objs to separate func #527

Merged
merged 4 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion skyplane/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
import skyplane.cli.experiments
from skyplane import config_path, exceptions, skyplane_root, cloud_config, tmp_log_dir
from skyplane.cli.common import print_header, console
from skyplane.cli.cli_impl.cp_replicate import generate_full_transferobjlist, generate_topology, confirm_transfer, launch_replication_job
from skyplane.cli.cli_impl.cp_replicate import (
enrich_dest_objs,
generate_full_transferobjlist,
generate_topology,
confirm_transfer,
launch_replication_job,
)
from skyplane.replicate.replication_plan import ReplicationJob
from skyplane.cli.cli_impl.init import load_aws_config, load_azure_config, load_gcp_config
from skyplane.cli.common import parse_path, query_instances
Expand Down Expand Up @@ -335,6 +341,8 @@ def sync(

raise typer.Exit(1)

enrich_dest_objs(dst_region, path_dst, bucket_dst, [i[1] for i in full_transfer_pairs])

# filter out any transfer pairs that are already in the destination
transfer_pairs = []
for src_obj, dst_obj in full_transfer_pairs:
Expand Down
11 changes: 9 additions & 2 deletions skyplane/cli/cli_impl/cp_replicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ def generate_full_transferobjlist(
# dest_obj = ObjectStoreObject(dest_region.split(":")[0], dest_bucket, dest_key)
dest_objs.append(dest_obj)

return list(zip(source_objs, dest_objs))


def enrich_dest_objs(dest_region: str, dest_prefix: str, dest_bucket: str, dest_objs: list):
"""
For skyplane sync, we enrich dest obj metadata with our existing dest obj metadata from the dest bucket following a query.
"""
dest_iface = ObjectStoreInterface.create(dest_region, dest_bucket)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a docstring


# query destination at dest_key
logger.fs.debug(f"Querying objects in {dest_bucket}")
dest_objs_keys = {obj.key for obj in dest_objs}
Expand All @@ -210,8 +219,6 @@ def generate_full_transferobjlist(
dest_obj.size = found_dest_objs[dest_obj.key].size
dest_obj.last_modified = found_dest_objs[dest_obj.key].last_modified

return list(zip(source_objs, dest_objs))


def confirm_transfer(topo: ReplicationTopology, job: ReplicationJob, ask_to_confirm_transfer=True):
console.print(
Expand Down