Skip to content

Commit 18719b8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9b487f0 commit 18719b8

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/lightning/data/processing/data_processor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
_TORCH_GREATER_EQUAL_2_1_0,
3030
)
3131
from lightning.data.processing.readers import BaseReader
32+
from lightning.data.processing.utilities import _create_dataset
3233
from lightning.data.streaming import Cache
3334
from lightning.data.streaming.cache import Dir
3435
from lightning.data.streaming.client import S3Client
3536
from lightning.data.streaming.resolver import _resolve_dir
3637
from lightning.data.utilities.broadcast import broadcast_object
3738
from lightning.data.utilities.packing import _pack_greedily
38-
from lightning.data.processing.utilities import _create_dataset
3939

4040
if _TORCH_GREATER_EQUAL_2_1_0:
4141
from torch.utils._pytree import tree_flatten, tree_unflatten, treespec_loads

src/lightning/data/processing/utilities.py

+9-13
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,19 @@
33
import urllib
44
from contextlib import contextmanager
55
from subprocess import Popen
6-
from typing import Any, Callable, Optional, Tuple
6+
from typing import Any, Callable, List, Optional, Tuple, Union
77

8-
from lightning.data.constants import _IS_IN_STUDIO, _LIGHTNING_CLOUD_LATEST
9-
10-
from typing import Optional, List, Tuple, Union
11-
import os
128
import urllib3
139

10+
from lightning.data.constants import _IS_IN_STUDIO, _LIGHTNING_CLOUD_LATEST
11+
1412
if _LIGHTNING_CLOUD_LATEST:
15-
from lightning_cloud.rest_client import LightningClient
1613
from lightning_cloud.openapi import (
1714
ProjectIdDatasetsBody,
1815
V1DatasetType,
1916
)
2017
from lightning_cloud.openapi.rest import ApiException
18+
from lightning_cloud.rest_client import LightningClient
2119

2220

2321
def _create_dataset(
@@ -34,9 +32,7 @@ def _create_dataset(
3432
name: Optional[str] = None,
3533
version: Optional[int] = None,
3634
):
37-
"""
38-
Create a dataset with metadata information about its source and destination
39-
"""
35+
"""Create a dataset with metadata information about its source and destination."""
4036
project_id = os.getenv("LIGHTNING_CLOUD_PROJECT_ID", None)
4137
cluster_id = os.getenv("LIGHTNING_CLUSTER_ID", None)
4238
user_id = os.getenv("LIGHTNING_USER_ID", None)
@@ -71,14 +67,14 @@ def _create_dataset(
7167
type=dataset_type,
7268
version=version,
7369
),
74-
project_id=project_id
70+
project_id=project_id,
7571
)
7672
except (ApiException, urllib3.exceptions.HTTPError) as ex:
77-
# Note: This function can be called in a distributed way.
73+
# Note: This function can be called in a distributed way.
7874
# There is a race condition where one machine might create the entry before another machine
7975
# and this request would fail with duplicated key
80-
# In this case, it is fine not to raise
81-
if 'already exists' in str(ex.body):
76+
# In this case, it is fine not to raise
77+
if "already exists" in str(ex.body):
8278
pass
8379
else:
8480
raise ex

0 commit comments

Comments
 (0)