Skip to content

Commit 59d705e

Browse files
committed
Revert "[FSTORE-1439][APPEND] Apply ruff formatting and fixes to the merged repo (logicalclocks#232)"
This reverts commit a612df1.
1 parent d741178 commit 59d705e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+229
-322
lines changed

python/hopsworks/client/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
from hopsworks.client import external, hopsworks
1818

19-
2019
_client = None
2120
_python_version = None
2221

python/hopsworks/client/base.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
#
1616

1717
import os
18+
import furl
1819
from abc import ABC, abstractmethod
1920

20-
import furl
2121
import requests
2222
import urllib3
23-
from hopsworks.client import auth, exceptions
23+
24+
from hopsworks.client import exceptions, auth
2425
from hopsworks.decorators import connected
2526

2627

python/hopsworks/client/hopsworks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
from pathlib import Path
2121

2222
import requests
23-
from hopsworks.client import auth, base
2423

24+
from hopsworks.client import base, auth
2525

2626
try:
2727
import jks
@@ -134,7 +134,7 @@ def _convert_jks_to_pem(self, jks_path, keystore_pw):
134134
ca_certs = ""
135135

136136
# Convert CA Certificates into PEM format and append to string
137-
for _alias, c in ks.certs.items():
137+
for alias, c in ks.certs.items():
138138
ca_certs = ca_certs + self._bytes_to_pem_str(c.cert, "CERTIFICATE")
139139
return ca_certs
140140

python/hopsworks/connection.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
import os
1818
import re
19-
import sys
2019
import warnings
20+
import sys
2121

22-
from hopsworks import client, version
23-
from hopsworks.core import project_api, secret_api, variable_api
24-
from hopsworks.decorators import connected, not_connected
2522
from requests.exceptions import ConnectionError
2623

24+
from hopsworks.decorators import connected, not_connected
25+
from hopsworks import client, version
26+
from hopsworks.core import project_api, secret_api, variable_api
2727

2828
HOPSWORKS_PORT_DEFAULT = 443
2929
HOSTNAME_VERIFICATION_DEFAULT = True
@@ -210,8 +210,7 @@ def _check_compatibility(self):
210210
warnings.warn(
211211
"The installed hopsworks client version {0} may not be compatible with the connected Hopsworks backend version {1}. \nTo ensure compatibility please install the latest bug fix release matching the minor version of your backend ({2}) by running 'pip install hopsworks=={2}.*'".format(
212212
client_version, backend_version, major_minor_backend
213-
),
214-
stacklevel=1,
213+
)
215214
)
216215
sys.stderr.flush()
217216

python/hopsworks/core/dataset_api.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
# limitations under the License.
1515
#
1616

17-
import copy
18-
import logging
1917
import math
2018
import os
21-
import shutil
2219
import time
23-
from concurrent.futures import ThreadPoolExecutor, wait
20+
from tqdm.auto import tqdm
21+
import shutil
22+
import logging
23+
import copy
2424

2525
from hopsworks import client
26-
from hopsworks.client.exceptions import DatasetException, RestAPIError
27-
from tqdm.auto import tqdm
26+
from hopsworks.client.exceptions import RestAPIError
27+
from hopsworks.client.exceptions import DatasetException
28+
from concurrent.futures import ThreadPoolExecutor, wait
2829

2930

3031
class Chunk:

python/hopsworks/core/environment_api.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ def __init__(
3232

3333
self._environment_engine = environment_engine.EnvironmentEngine(project_id)
3434

35-
def create_environment(
36-
self,
37-
name: str,
38-
description: Optional[str] = None,
39-
base_environment_name: Optional[str] = "python-feature-pipeline",
40-
await_creation: Optional[bool] = True,
41-
) -> environment.Environment:
35+
def create_environment(self, name: str, description: Optional[str] = None, base_environment_name: Optional[str] = "python-feature-pipeline", await_creation: Optional[bool] = True) -> environment.Environment:
4236
"""Create Python environment for the project
4337
4438
```python
@@ -72,14 +66,13 @@ def create_environment(
7266
name,
7367
]
7468
headers = {"content-type": "application/json"}
75-
data = {
76-
"name": name,
77-
"baseImage": {"name": base_environment_name, "description": description},
78-
}
69+
data = {"name": name,
70+
"baseImage": {
71+
"name": base_environment_name,
72+
"description": description
73+
}}
7974
env = environment.Environment.from_response_json(
80-
_client._send_request(
81-
"POST", path_params, headers=headers, data=json.dumps(data)
82-
),
75+
_client._send_request("POST", path_params, headers=headers, data=json.dumps(data)),
8376
self._project_id,
8477
self._project_name,
8578
)
@@ -155,4 +148,4 @@ def _delete(self, name):
155148
name,
156149
]
157150
headers = {"content-type": "application/json"}
158-
(_client._send_request("DELETE", path_params, headers=headers),)
151+
_client._send_request("DELETE", path_params, headers=headers),

python/hopsworks/core/flink_cluster_api.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
# limitations under the License.
1515
#
1616

17-
import json
1817
import os
19-
20-
from hopsworks import client, flink_cluster, job, util
21-
from hopsworks.client.exceptions import RestAPIError
18+
import json
19+
from hopsworks import client, flink_cluster, util, job
2220
from hopsworks.core import job_api
2321

2422

@@ -71,9 +69,7 @@ def setup_cluster(self, name: str, config=None):
7169
# If the job already exists, retrieve it
7270
_flink_cluster = self.get_cluster(name)
7371
if _flink_cluster._job.job_type != "FLINK":
74-
raise RestAPIError(
75-
"This is not a Flink cluster. Please use different name to create new Flink cluster"
76-
)
72+
raise "This is not a Flink cluster. Please use different name to create new Flink cluster"
7773
return _flink_cluster
7874
else:
7975
# If the job doesn't exists, create a new job

python/hopsworks/core/git_api.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
# limitations under the License.
1515
#
1616

17-
import json
18-
import logging
19-
from typing import List, Union
20-
2117
from hopsworks import (
2218
client,
23-
git_commit,
24-
git_file_status,
25-
git_op_execution,
2619
git_repo,
20+
git_op_execution,
2721
util,
22+
git_commit,
23+
git_file_status,
2824
)
2925
from hopsworks.client.exceptions import GitException
30-
from hopsworks.core import git_provider_api
3126
from hopsworks.engine import git_engine
27+
from hopsworks.core import git_provider_api
28+
from typing import List, Union
3229
from hopsworks.git_file_status import GitFileStatus
3330

31+
import json
32+
import logging
33+
3434

3535
class GitApi:
3636
def __init__(
@@ -347,7 +347,7 @@ def _status(self, repo_id):
347347

348348
status_dict = json.loads(git_op.command_result_message)
349349
file_status = None
350-
if status_dict is not None and isinstance(status_dict["status"], list):
350+
if status_dict is not None and type(status_dict["status"]) is list:
351351
file_status = []
352352
for status in status_dict["status"]:
353353
file_status.append(

python/hopsworks/core/git_provider_api.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
# limitations under the License.
1515
#
1616

17-
import json
18-
1917
from hopsworks import client, git_provider
20-
from hopsworks.client.exceptions import GitException
2118
from hopsworks.engine import git_engine
19+
from hopsworks.client.exceptions import GitException
20+
21+
import json
2222

2323

2424
class GitProviderApi:

python/hopsworks/core/job_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import json
1818

19-
from hopsworks import client, job, job_schedule, util
19+
from hopsworks import client, job, util, job_schedule
2020
from hopsworks.client.exceptions import RestAPIError
2121

2222

python/hopsworks/core/kafka_api.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
# limitations under the License.
1515
#
1616

17+
from hopsworks import client, kafka_topic, kafka_schema, constants
18+
from hopsworks.client.exceptions import KafkaException
1719
import json
1820
import socket
19-
20-
from hopsworks import client, constants, kafka_schema, kafka_topic
21-
from hopsworks.client.exceptions import KafkaException
2221
from hopsworks.client.external import Client
2322

2423

@@ -367,7 +366,7 @@ def get_default_config(self):
367366
constants.KAFKA_SSL_CONFIG.SSL_ENDPOINT_IDENTIFICATION_ALGORITHM_CONFIG: "none",
368367
}
369368
_client = client.get_instance()
370-
if type(_client) is Client:
369+
if type(_client) == Client:
371370
config[constants.KAFKA_PRODUCER_CONFIG.BOOTSTRAP_SERVERS_CONFIG] = ",".join(
372371
[
373372
endpoint.replace("EXTERNAL://", "")

python/hopsworks/core/secret_api.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ def get_secret(self, name: str, owner: str = None) -> secret.Secret:
7272
"shared",
7373
]
7474

75-
return secret.Secret.from_response_json(
76-
_client._send_request("GET", path_params, query_params=query_params)
77-
)[0]
75+
return secret.Secret.from_response_json(_client._send_request("GET", path_params, query_params=query_params))[0]
7876

7977
def get(self, name: str, owner: str = None) -> str:
8078
"""Get the secret's value.
@@ -92,20 +90,16 @@ def get(self, name: str, owner: str = None) -> str:
9290
return self.get_secret(name=name, owner=owner).value
9391
except RestAPIError as e:
9492
if (
95-
e.response.json().get("errorCode", "") == 160048
96-
and e.response.status_code == 404
97-
and util.is_interactive()
93+
e.response.json().get("errorCode", "") == 160048
94+
and e.response.status_code == 404
95+
and util.is_interactive()
9896
):
99-
secret_input = getpass.getpass(
100-
prompt="\nCould not find secret, enter value here to create it: "
101-
)
97+
secret_input = getpass.getpass(prompt="\nCould not find secret, enter value here to create it: ")
10298
return self.create_secret(name, secret_input).value
10399
else:
104100
raise e
105101

106-
def create_secret(
107-
self, name: str, value: str, project: str = None
108-
) -> secret.Secret:
102+
def create_secret(self, name: str, value: str, project: str = None) -> secret.Secret:
109103
"""Create a new secret.
110104
111105
```python

python/hopsworks/engine/execution_engine.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
# limitations under the License.
1515
#
1616

17-
import logging
17+
from hopsworks.core import dataset_api, execution_api
1818
import os
19+
import logging
1920
import time
2021
import uuid
2122

2223
from hopsworks.client.exceptions import JobExecutionException, RestAPIError
23-
from hopsworks.core import dataset_api, execution_api
2424

2525

2626
class ExecutionEngine:

python/hopsworks/engine/git_engine.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414
# limitations under the License.
1515
#
1616

17-
import logging
18-
import time
19-
20-
from hopsworks.client.exceptions import GitException
2117
from hopsworks.core import git_op_execution_api
18+
from hopsworks.client.exceptions import GitException
19+
import time
20+
import logging
2221

2322

2423
class GitEngine:

python/hopsworks/environment.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,16 @@ def install_wheel(self, path: str, await_installation: Optional[bool] = True):
133133
"packageSource": "WHEEL",
134134
}
135135

136-
library_rest = self._library_api._install(library_name, self.name, library_spec)
136+
library_rest = self._library_api._install(
137+
library_name, self.name, library_spec
138+
)
137139

138140
if await_installation:
139-
return self._environment_engine.await_library_command(
140-
self.name, library_name
141-
)
141+
return self._environment_engine.await_library_command(self.name, library_name)
142142

143143
return library_rest
144144

145-
def install_requirements(
146-
self, path: str, await_installation: Optional[bool] = True
147-
):
145+
def install_requirements(self, path: str, await_installation: Optional[bool] = True):
148146
"""Install libraries specified in a requirements.txt file
149147
150148
```python
@@ -186,12 +184,12 @@ def install_requirements(
186184
"packageSource": "REQUIREMENTS_TXT",
187185
}
188186

189-
library_rest = self._library_api._install(library_name, self.name, library_spec)
187+
library_rest = self._library_api._install(
188+
library_name, self.name, library_spec
189+
)
190190

191191
if await_installation:
192-
return self._environment_engine.await_library_command(
193-
self.name, library_name
194-
)
192+
return self._environment_engine.await_library_command(self.name, library_name)
195193

196194
return library_rest
197195

python/hopsworks/flink_cluster.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#
1616

1717
import time
18-
19-
from hopsworks import util
20-
from hopsworks.core import execution_api, flink_cluster_api
2118
from hopsworks.engine import execution_engine
19+
from hopsworks.core import execution_api
20+
from hopsworks.core import flink_cluster_api
21+
from hopsworks import util
2222

2323

2424
class FlinkCluster:

python/hopsworks/git_commit.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
# limitations under the License.
1515
#
1616

17-
import json
18-
19-
import humps
2017
from hopsworks import util
18+
import humps
19+
import json
2120

2221

2322
class GitCommit:

python/hopsworks/git_file_status.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# limitations under the License.
1515
#
1616

17+
import humps
1718
import json
1819

19-
import humps
2020
from hopsworks import util
2121

2222

0 commit comments

Comments
 (0)