Skip to content

Commit

Permalink
Merge pull request #485 from latchbio/rahuldesai1/fix-results-publish
Browse files Browse the repository at this point in the history
fix publishing results for latch:/// domain
  • Loading branch information
rahuldesai1 authored Aug 8, 2024
2 parents 9900235 + ac10c98 commit 07b8655
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Types of changes

# Latch SDK Changelog

## 2.50.3 - 2024-08-08

### Fixed

* Nextflow
- Normalize result paths before publishing results

## 2.50.2 - 2024-08-07

### Dependencies
Expand Down
14 changes: 9 additions & 5 deletions latch/executions.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
import re
from dataclasses import dataclass
from typing import List, Optional, Union
from typing import List, Optional

import click
import gql
from latch_sdk_gql.execute import execute

from latch.types.directory import LatchDir
from latch.types.file import LatchFile
from latch_cli.utils.path import normalize_path

pod_name_regex = re.compile(
r"""
Expand Down Expand Up @@ -109,8 +108,9 @@ def rename_current_execution(name: str):


def add_execution_results(results: List[str]):
token = os.environ.get("FLYTE_INTERNAL_EXECUTION_ID", None)
if token is None:
token = os.environ.get("FLYTE_INTERNAL_EXECUTION_ID")
workspace_id = os.environ.get("FLYTE_INTERNAL_EXECUTION_PROJECT")
if token is None or workspace_id is None:
# noop during local execution / testing
click.secho(
"Running in local execution context - skip adding output results.",
Expand All @@ -119,6 +119,10 @@ def add_execution_results(results: List[str]):
)
return

results = [
normalize_path(r, workspace=workspace_id, assume_remote=True) for r in results
]

execute(
gql.gql("""
mutation addExecutionResults(
Expand Down
12 changes: 8 additions & 4 deletions latch_cli/utils/path.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
from pathlib import Path
from textwrap import dedent
from typing import Optional
from urllib.parse import urlparse

import click
Expand Down Expand Up @@ -85,8 +86,9 @@ def append_scheme(path: str, *, assume_remote: bool = False) -> str:
# latch:///a/b/c => latch://xxx.account/a/b/c
# latch://shared/a/b/c => latch://shared.xxx.account/a/b/c
# latch://any_other_domain/a/b/c => unchanged
def append_domain(path: str) -> str:
workspace = user_config.workspace_id
def append_domain(path: str, *, workspace: Optional[int] = None) -> str:
if workspace is None:
workspace = user_config.workspace_id

parsed = urlparse(path)
dom = parsed.netloc
Expand Down Expand Up @@ -138,13 +140,15 @@ def is_account_relative(path: str) -> bool:
return match["account_relative"] is not None


def normalize_path(path: str, *, assume_remote: bool = False) -> str:
def normalize_path(
path: str, *, assume_remote: bool = False, workspace: Optional[int] = None
) -> str:
path = append_scheme(path, assume_remote=assume_remote)

if path.startswith("file://"):
return path

return append_domain(path)
return append_domain(path, workspace=workspace)


auth = re.compile(
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

setup(
name="latch",
version="v2.50.2",
version="v2.50.3",
author_email="[email protected]",
description="The Latch SDK",
packages=find_packages(),
Expand Down

0 comments on commit 07b8655

Please sign in to comment.