Skip to content

Commit f62f55d

Browse files
authored
Merge pull request #3184 from SwissDataScienceCenter/release/v1.8.1
chore: release v1.8.1
2 parents fe21509 + f43b729 commit f62f55d

File tree

16 files changed

+244
-99
lines changed

16 files changed

+244
-99
lines changed

CHANGES.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@
1818
Changes
1919
=======
2020

21+
`1.8.1 <https://github.com/SwissDataScienceCenter/renku-python/compare/v1.8.0...v1.8.1>`__ (2022-10-26)
22+
-------------------------------------------------------------------------------------------------------
23+
24+
Bug Fixes
25+
~~~~~~~~~
26+
27+
- **service:** don't change working directory, as it isn't thread-safe
28+
(`#3182 <https://github.com/SwissDataScienceCenter/renku-python/issues/3182>`__)
29+
(`909b001 <https://github.com/SwissDataScienceCenter/renku-python/commit/909b001fb0a0ac3e6deb2d03f5f9218a7ee7d42e>`__)
30+
31+
Features
32+
~~~~~~~~
33+
34+
- **dataset:** support non-AWS S3 URI
35+
(`#3159 <https://github.com/SwissDataScienceCenter/renku-python/issues/3159>`__)
36+
(`b81bbe5 <https://github.com/SwissDataScienceCenter/renku-python/commit/b81bbe58b65ac0cd1048a05fae87550d3db4e991>`__)
37+
2138
`1.8.0 <https://github.com/SwissDataScienceCenter/renku-python/compare/v1.7.1...v1.8.0>`__ (2022-10-14)
22-
=======================================================================================================
39+
-------------------------------------------------------------------------------------------------------
2340

2441
Bug Fixes
2542
~~~~~~~~~

helm-chart/renku-core/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ appVersion: "1.0"
33
description: A Helm chart for Kubernetes
44
name: renku-core
55
icon: https://avatars0.githubusercontent.com/u/53332360?s=400&u=a4311d22842343604ef61a8c8a1e5793209a67e9&v=4
6-
version: 1.8.0
6+
version: 1.8.1

helm-chart/renku-core/templates/deployment-nginx.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ spec:
1414
labels:
1515
app.kubernetes.io/name: {{ include "renku-core.fullname" $ }}-nginx
1616
spec:
17+
automountServiceAccountToken: false
1718
containers:
1819
- name: nginx
1920
image: bitnami/nginx:1.21.4

helm-chart/renku-core/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spec:
4949
{{- include "certificates.initContainer" $ | nindent 8 }}
5050
securityContext:
5151
{{- toYaml $.Values.podSecurityContext | nindent 8 }}
52+
automountServiceAccountToken: false
5253
containers:
5354
{{ if $.Values.metrics.enabled }}
5455
- name: {{ $.Chart.Name}}-rqmetrics

helm-chart/renku-core/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ versions:
9696
fullnameOverride: ""
9797
image:
9898
repository: renku/renku-core
99-
tag: "v1.8.0"
99+
tag: "v1.8.1"
100100
pullPolicy: IfNotPresent
101101
v8:
102102
name: v8

renku/command/command_builder/command.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def __init__(self) -> None:
143143
self._finalized: bool = False
144144
self._track_std_streams: bool = False
145145
self._working_directory: Optional[str] = None
146+
self._context_added: bool = False
146147

147148
def __getattr__(self, name: str) -> Any:
148149
"""Bubble up attributes of wrapped builders."""
@@ -165,8 +166,10 @@ def _injection_pre_hook(self, builder: "Command", context: dict, *args, **kwargs
165166
builder("Command"): Current ``CommandBuilder``.
166167
context(dict): Current context dictionary.
167168
"""
168-
path = get_git_path(self._working_directory or ".")
169-
project_context.push_path(path)
169+
if not project_context.has_context():
170+
path = get_git_path(self._working_directory or ".")
171+
project_context.push_path(path)
172+
self._context_added = True
170173

171174
context["bindings"] = {}
172175
context["constructor_bindings"] = {}
@@ -192,7 +195,8 @@ def _post_hook(self, builder: "Command", context: dict, result: "CommandResult",
192195
"""
193196
remove_injector()
194197

195-
project_context.pop_context()
198+
if self._context_added:
199+
project_context.pop_context()
196200

197201
if result.error:
198202
raise result.error

renku/core/dataset/providers/s3.py

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import re
2121
import urllib
2222
from pathlib import Path
23-
from typing import TYPE_CHECKING, List, Optional, Tuple
23+
from typing import TYPE_CHECKING, List, Optional, Tuple, cast
2424

2525
from renku.core import errors
2626
from renku.core.dataset.providers.api import ProviderApi, ProviderCredentials, ProviderPriority
@@ -43,8 +43,11 @@ class S3Provider(ProviderApi):
4343

4444
def __init__(self, uri: Optional[str]):
4545
super().__init__(uri=uri)
46-
bucket, _ = extract_bucket_and_path(uri=self.uri)
46+
47+
endpoint, bucket, _ = parse_s3_uri(uri=self.uri)
48+
4749
self._bucket: str = bucket
50+
self._endpoint: str = endpoint
4851

4952
@staticmethod
5053
def supports(uri: str) -> bool:
@@ -100,16 +103,16 @@ def add(uri: str, destination: Path, **kwargs) -> List["DatasetAddMetadata"]:
100103
if not storage.exists(uri):
101104
raise errors.ParameterError(f"S3 bucket '{uri}' doesn't exists.")
102105

103-
repository = project_context.repository
106+
destination_path_in_repo = Path(destination).relative_to(project_context.repository.path)
104107
hashes = storage.get_hashes(uri=uri)
105108
return [
106109
DatasetAddMetadata(
107-
entity_path=Path(destination).relative_to(repository.path) / hash.path,
110+
entity_path=destination_path_in_repo / hash.path,
108111
url=hash.base_uri,
109112
action=DatasetAddAction.NONE,
110113
based_on=RemoteEntity(checksum=hash.hash if hash.hash else "", url=hash.base_uri, path=hash.path),
111114
source=Path(hash.full_uri),
112-
destination=Path(destination).relative_to(repository.path),
115+
destination=destination_path_in_repo,
113116
gitignored=True,
114117
)
115118
for hash in hashes
@@ -120,6 +123,11 @@ def bucket(self) -> str:
120123
"""Return S3 bucket name."""
121124
return self._bucket
122125

126+
@property
127+
def endpoint(self) -> str:
128+
"""Return S3 bucket endpoint."""
129+
return self._endpoint
130+
123131
def on_create(self, dataset: "Dataset") -> None:
124132
"""Hook to perform provider-specific actions on a newly-created dataset."""
125133
credentials = S3Credentials(provider=self)
@@ -145,15 +153,39 @@ def get_credentials_names() -> Tuple[str, ...]:
145153
"""Return a tuple of the required credentials for a provider."""
146154
return "Access Key ID", "Secret Access Key"
147155

156+
@property
157+
def provider(self) -> S3Provider:
158+
"""Return the associated provider instance."""
159+
return cast(S3Provider, self._provider)
160+
161+
def get_credentials_section_name(self) -> str:
162+
"""Get section name for storing credentials.
163+
164+
NOTE: This methods should be overridden by subclasses to allow multiple credentials per providers if needed.
165+
"""
166+
return self.provider.endpoint.lower()
148167

149-
def extract_bucket_and_path(uri: str) -> Tuple[str, str]:
150-
"""Extract bucket name and path within the bucket from a given URI.
151168

152-
NOTE: We only support s3://<bucket-name>/<path> at the moment.
169+
def create_renku_s3_uri(uri: str) -> str:
170+
"""Create a S3 URI to work with Renku."""
171+
_, bucket, path = parse_s3_uri(uri=uri)
172+
173+
return f"s3://{bucket}/{path}"
174+
175+
176+
def parse_s3_uri(uri: str) -> Tuple[str, str, str]:
177+
"""Extract endpoint, bucket name, and path within the bucket from a given URI.
178+
179+
NOTE: We only support s3://<endpoint>/<bucket-name>/<path> at the moment.
153180
"""
154181
parsed_uri = urllib.parse.urlparse(uri)
155182

156-
if parsed_uri.scheme.lower() != "s3" or not parsed_uri.netloc:
157-
raise errors.ParameterError(f"Invalid S3 URI: {uri}")
183+
endpoint = parsed_uri.netloc
184+
path = parsed_uri.path.strip("/")
185+
186+
if parsed_uri.scheme.lower() != "s3" or not endpoint or not path:
187+
raise errors.ParameterError(f"Invalid S3 URI: {uri}. Valid format is 's3://<endpoint>/<bucket-name>/<path>'")
188+
189+
bucket, _, path = path.partition("/")
158190

159-
return parsed_uri.netloc, parsed_uri.path
191+
return endpoint, bucket, path.strip("/")

renku/core/interface/storage.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import abc
2121
from dataclasses import dataclass
2222
from pathlib import Path
23-
from typing import TYPE_CHECKING, List, Optional, Union
23+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
2424

2525
if TYPE_CHECKING:
2626
from renku.core.dataset.providers.api import ProviderApi, ProviderCredentials
@@ -70,15 +70,20 @@ def provider(self) -> "ProviderApi":
7070
return self._provider
7171

7272
@abc.abstractmethod
73-
def copy(self, source: Union[Path, str], destination: Union[Path, str]) -> None:
74-
"""Copy data from ``source`` to ``destination``."""
73+
def copy(self, uri: str, destination: Union[Path, str]) -> None:
74+
"""Copy data from ``uri`` to ``destination``."""
7575
raise NotImplementedError
7676

7777
@abc.abstractmethod
7878
def exists(self, uri: str) -> bool:
7979
"""Checks if a remote storage URI exists."""
8080
raise NotImplementedError
8181

82+
@abc.abstractmethod
83+
def get_configurations(self) -> Dict[str, str]:
84+
"""Get required configurations to access the storage."""
85+
raise NotImplementedError
86+
8287
@abc.abstractmethod
8388
def get_hashes(self, uri: str, hash_type: str = "md5") -> List[FileHash]:
8489
"""Get the hashes of all files at the uri."""
@@ -90,6 +95,5 @@ def mount(self, path: Union[Path, str]) -> None:
9095
raise NotImplementedError
9196

9297
@abc.abstractmethod
93-
def set_configurations(self) -> None:
94-
"""Set required configurations to access the storage."""
95-
raise NotImplementedError
98+
def run_rclone_command(self, command: str, uri: str, *args, **kwargs) -> Any:
99+
"""Run a RClone command by possibly add storage-specific flags."""

renku/core/util/contexts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def renku_project_context(path, check_git_path=True):
116116
if check_git_path:
117117
path = get_git_path(path)
118118

119-
with project_context.with_path(path=path), chdir(path):
119+
with project_context.with_path(path=path):
120120
project_context.external_storage_requested = True
121121
yield project_context.path
122122

renku/domain_model/project_context.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ def docker_path(self):
9999
"""Path to the Dockerfile."""
100100
return self.path / DOCKERFILE
101101

102-
@property
103-
def empty(self) -> bool:
104-
"""Return True if there is no pushed context."""
105-
return not bool(self._context_stack)
106-
107102
@property
108103
def global_config_dir(self) -> str:
109104
"""Return user's config directory."""

0 commit comments

Comments
 (0)