Skip to content

Commit bc69b2d

Browse files
committed
Use new exportToSeafowl gql mutation for Seafowl VDB exports
1 parent 04a2b9f commit bc69b2d

3 files changed

Lines changed: 23 additions & 17 deletions

File tree

splitgraph/cloud/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
REPO_CONDITIONS,
6767
REPO_PARAMS,
6868
START_EXPORT,
69+
START_EXPORT_VDB_TO_SEAFOWL,
6970
START_LOAD,
70-
START_SYNC_VDB_TO_SEAFOWL,
7171
)
7272
from splitgraph.config import CONFIG
7373
from splitgraph.config.config import (
@@ -1155,11 +1155,11 @@ def provision_ephemeral_tunnel(self) -> Tuple[str, str, int, str, int]:
11551155
def start_seafowl_sync(self, vdb_id: str, url: str, secret: str) -> str:
11561156
response = self._gql(
11571157
{
1158-
"query": START_SYNC_VDB_TO_SEAFOWL,
1159-
"operationName": "syncToSeafowl",
1158+
"query": START_EXPORT_VDB_TO_SEAFOWL,
1159+
"operationName": "exportToSeafowl",
11601160
"variables": {"url": url, "secret": secret, "vdbId": vdb_id},
11611161
},
11621162
handle_errors=True,
11631163
anonymous_ok=False,
11641164
)
1165-
return cast(str, response.json()["data"]["syncToSeafowl"]["id"])
1165+
return cast(str, response.json()["data"]["exportToSeafowl"]["vdbs"][0]["jobId"])

splitgraph/cloud/queries.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,20 @@
317317
}
318318
"""
319319

320-
START_SYNC_VDB_TO_SEAFOWL = """mutation syncToSeafowl($url: String!, $secret: String!, $vdbId: String!) {
321-
syncToSeafowl(
322-
target: {
323-
url: $url,
324-
secret: $secret
325-
},
326-
vdbId: $vdbId
327-
) {
328-
id
320+
START_EXPORT_VDB_TO_SEAFOWL = """mutation exportToSeafowl(
321+
$url: String!
322+
$secret: String!
323+
$vdbId: String!
324+
) {
325+
exportToSeafowl(
326+
seafowlInstance: {
327+
selfHosted: { url: $url, secret: $secret}
328+
}
329+
vdbs: [{ source: { vdbId: $vdbId } }]
330+
) {
331+
vdbs {
332+
jobId
329333
}
334+
}
330335
}
331336
"""

splitgraph/commandline/cloud.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,12 +1310,12 @@ def tunnel_c(remote: str, local_address: str, namespace_and_repository: Optional
13101310
start_repository_tunnel(remote, local_address, namespace_and_repository)
13111311

13121312

1313-
@click.command("sync-to-seafowl")
1313+
@click.command("export-to-seafowl")
13141314
@click.option("--remote", default="data.splitgraph.com", help="Name of the remote registry to use.")
13151315
@click.option("--password", prompt=True, hide_input=True, confirmation_prompt=False)
13161316
@click.argument("vdb_id", type=str)
13171317
@click.argument("seafowl_hostname", type=str)
1318-
def sync_to_seafowl_c(remote: str, password: str, vdb_id: str, seafowl_hostname: str):
1318+
def export_to_seafowl_c(remote: str, password: str, vdb_id: str, seafowl_hostname: str):
13191319
"""
13201320
Sync the tables within a Splitgraph VDB to a Seafowl instance.
13211321
@@ -1328,7 +1328,8 @@ def sync_to_seafowl_c(remote: str, password: str, vdb_id: str, seafowl_hostname:
13281328
final_status = wait_for_job(task_id, lambda: client.get_export_job_status(task_id))
13291329
if final_status.status == "SUCCESS":
13301330
assert final_status.output
1331-
tables = [f"{sync_item[0]}.{sync_item[1]}" for sync_item in final_status.output["tables"]]
1331+
# final_status.output["tables"] : [(source_query, target_dbname, target_schema, target_table, download_url)]
1332+
tables = [f"{sync_item[2]}.{sync_item[3]}" for sync_item in final_status.output["tables"]]
13321333
tables.sort()
13331334
click.echo("Sync complete for tables: %s" % ", ".join(tables))
13341335
else:
@@ -1363,4 +1364,4 @@ def cloud_c():
13631364
cloud_c.add_command(validate_c)
13641365
cloud_c.add_command(seed_c)
13651366
cloud_c.add_command(tunnel_c)
1366-
cloud_c.add_command(sync_to_seafowl_c)
1367+
cloud_c.add_command(export_to_seafowl_c)

0 commit comments

Comments
 (0)