Skip to content

Commit

Permalink
Create separate oneshot session per transformation (#1371)
Browse files Browse the repository at this point in the history
Co-authored-by: anders-albert <anders0albert@gmail.com>
  • Loading branch information
dmivankov and doctrino authored Feb 22, 2025
1 parent f7ad946 commit 1d5df57
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cognite_toolkit/_cdf_tk/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,6 @@ def run_transformation(self, client: ToolkitClient, external_ids: str | list[str
"""Run a transformation in CDF"""
if isinstance(external_ids, str):
external_ids = [external_ids]
session = client.iam.sessions.create(session_type="ONESHOT_TOKEN_EXCHANGE")
if session is None:
print("[bold red]ERROR:[/] Could not get a oneshot session.")
return False
try:
transformations: TransformationList = client.transformations.retrieve_multiple(external_ids=external_ids)
except CogniteAPIError as e:
Expand All @@ -650,8 +646,12 @@ def run_transformation(self, client: ToolkitClient, external_ids: str | list[str
if transformations is None or len(transformations) == 0:
print(f"[bold red]ERROR:[/] Could not find transformation with external_id {external_ids}")
return False
nonce = NonceCredentials(session_id=session.id, nonce=session.nonce, cdf_project_name=client.config.project)
for transformation in transformations:
session = client.iam.sessions.create(session_type="ONESHOT_TOKEN_EXCHANGE")
if session is None:
print("[bold red]ERROR:[/] Could not get a oneshot session.")
return False
nonce = NonceCredentials(session_id=session.id, nonce=session.nonce, cdf_project_name=client.config.project)
transformation.source_nonce = nonce
transformation.destination_nonce = nonce
try:
Expand Down

0 comments on commit 1d5df57

Please sign in to comment.