Skip to content

Commit 261b9ea

Browse files
[pre-commit.ci] Apply automatic pre-commit fixes
1 parent c0d3f9d commit 261b9ea

File tree

6 files changed

+46
-98
lines changed

6 files changed

+46
-98
lines changed

src/_nebari/deploy.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ def deploy_configuration(
1717
disable_checks: bool = False,
1818
) -> Dict[str, Any]:
1919
if config.prevent_deploy:
20-
raise ValueError(
21-
textwrap.dedent(
22-
"""
20+
raise ValueError(textwrap.dedent("""
2321
Deployment prevented due to the prevent_deploy setting in your nebari-config.yaml file.
2422
You could remove that field to deploy your Nebari, but please do NOT do so without fully understanding why that value was set in the first place.
2523
@@ -29,9 +27,7 @@ def deploy_configuration(
2927
3028
PLEASE get in touch with Nebari development team at https://github.com/nebari-dev/nebari for assistance in proceeding.
3129
Your data may be at risk without our guidance.
32-
"""
33-
)
34-
)
30+
"""))
3531

3632
if config.domain is None:
3733
logger.info(

src/_nebari/provider/cicd/linter.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ def generate_lint_message(config):
3636
# lint/validate nebari-config.yaml
3737
all_pass, messages, validate_code = nebari_validate(config)
3838

39-
pass_lint = textwrap.dedent(
40-
"""
39+
pass_lint = textwrap.dedent("""
4140
This is an automatic response from the Nebari linter.
4241
I just wanted to let you know that I linted your `nebari-config.yaml` in your PR and I didn't find any
4342
problems.
44-
"""
45-
)
43+
""")
4644

4745
# it should be better to parse this messages first
4846
bad_lint = (
@@ -56,12 +54,10 @@ def generate_lint_message(config):
5654

5755
if not pr_config:
5856
status = "no configuration file"
59-
message = textwrap.dedent(
60-
"""
57+
message = textwrap.dedent("""
6158
This is an automatic response from the Nebari linter.
6259
I was trying to look for the `nebari-config.yaml` file to lint for you, but couldn't find any...
63-
"""
64-
)
60+
""")
6561

6662
elif all_pass:
6763
status = "Success"

src/_nebari/upgrade.py

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,8 +1330,7 @@ def _version_specific_upgrade(
13301330
provider_full_name = provider_enum_name_map[provider]
13311331
if not config.get(provider_full_name, {}).get("node_groups", {}):
13321332
try:
1333-
text = textwrap.dedent(
1334-
f"""
1333+
text = textwrap.dedent(f"""
13351334
The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%.
13361335
This change will affect your current deployment, and will result in ~15 minutes of downtime during the upgrade step as the node groups are switched out, but shouldn't result in data loss.
13371336
@@ -1342,8 +1341,7 @@ def _version_specific_upgrade(
13421341
13431342
Would you like to upgrade to the cost effective node groups [purple]{config_filename}[/purple]?
13441343
If not, select "N" and the old default node groups will be added to the nebari config file.
1345-
"""
1346-
)
1344+
""")
13471345
continue_ = kwargs.get("attempt_fixes", False) or Confirm.ask(
13481346
text,
13491347
default=True,
@@ -1369,8 +1367,7 @@ def _version_specific_upgrade(
13691367
except KeyError:
13701368
pass
13711369
else:
1372-
text = textwrap.dedent(
1373-
"""
1370+
text = textwrap.dedent("""
13741371
The default node groups for GCP have been changed to cost efficient e2 family nodes reducing the running cost of Nebari on GCP by ~50%.
13751372
Consider upgrading your node group instance types to the new default configuration.
13761373
@@ -1379,8 +1376,7 @@ def _version_specific_upgrade(
13791376
As always, make sure to backup data before upgrading. See https://www.nebari.dev/docs/how-tos/manual-backup for more information.
13801377
13811378
The new default node groups instances are:
1382-
"""
1383-
)
1379+
""")
13841380
text += json.dumps(
13851381
{
13861382
"general": {"instance": "e2-highmem-4"},
@@ -1466,8 +1462,7 @@ def _version_specific_upgrade(
14661462

14671463
rich.print("\n ⚠️ Upgrade Warning ⚠️")
14681464

1469-
text = textwrap.dedent(
1470-
"""
1465+
text = textwrap.dedent("""
14711466
Please ensure no users are currently logged in prior to deploying this
14721467
update.
14731468
@@ -1488,8 +1483,7 @@ def _version_specific_upgrade(
14881483
mounted.
14891484
14901485
For more details check our [green][link=https://www.nebari.dev/docs/references/release/]release notes[/link][/green].
1491-
"""
1492-
)
1486+
""")
14931487
rich.print(text)
14941488
keycloak_admin = None
14951489

@@ -1521,15 +1515,11 @@ def _version_specific_upgrade(
15211515
)
15221516
except ValueError as e:
15231517
if "invalid_grant" in str(e):
1524-
rich.print(
1525-
textwrap.dedent(
1526-
"""
1518+
rich.print(textwrap.dedent("""
15271519
[red bold]Failed to connect to the Keycloak server.[/red bold]\n
15281520
[yellow]Please set the [bold]KEYCLOAK_ADMIN_USERNAME[/bold] and [bold]KEYCLOAK_ADMIN_PASSWORD[/bold]
15291521
environment variables with the Keycloak root credentials and try again.[/yellow]
1530-
"""
1531-
)
1532-
)
1522+
"""))
15331523
exit()
15341524
else:
15351525
# Handle other exceptions
@@ -1632,8 +1622,7 @@ def _version_specific_upgrade(
16321622
):
16331623
rich.print("\n ⚠️ Upgrade Warning ⚠️")
16341624

1635-
text = textwrap.dedent(
1636-
"""
1625+
text = textwrap.dedent("""
16371626
In this release, we have updated our maximum supported Kubernetes version from 1.29 to 1.31.
16381627
Please note that Nebari will NOT automatically upgrade your running Kubernetes version as part of
16391628
the redeployment process.
@@ -1644,8 +1633,7 @@ def _version_specific_upgrade(
16441633
16451634
For more information on upgrading Kubernetes for your specific cloud provider, please visit:
16461635
https://www.nebari.dev/docs/how-tos/kubernetes-version-upgrade
1647-
"""
1648-
)
1636+
""")
16491637
rich.print(text)
16501638

16511639
# If the Nebari provider is Azure, we must handle a major version upgrade
@@ -1656,9 +1644,7 @@ def _version_specific_upgrade(
16561644

16571645
if config.get("provider", "") == "azure":
16581646
rich.print("\n ⚠️ Azure Provider Upgrade Notice ⚠️")
1659-
rich.print(
1660-
textwrap.dedent(
1661-
"""
1647+
rich.print(textwrap.dedent("""
16621648
In this Nebari release, the Azure Terraform provider has been upgraded
16631649
from version 3.97.1 to 4.7.0. This major update includes internal schema
16641650
changes for certain resources, most notably the `azurerm_storage_account`.
@@ -1669,9 +1655,7 @@ def _version_specific_upgrade(
16691655
16701656
For detailed information on the Azure provider 4.x changes, please visit:
16711657
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/4.0-upgrade-guide
1672-
"""
1673-
)
1674-
)
1658+
"""))
16751659

16761660
# Prompt user for confirmation
16771661
continue_ = kwargs.get("attempt_fixes", False) or Confirm.ask(
@@ -1752,8 +1736,7 @@ def _version_specific_upgrade(
17521736
]:
17531737
rich.print("\n ⚠️ Node Taints Update ⚠️")
17541738

1755-
text = textwrap.dedent(
1756-
"""
1739+
text = textwrap.dedent("""
17571740
Starting with Nebari version 2025.4.1, node taints will be automatically applied to all non-general node groups by default.
17581741
Node taints help ensure that specific workloads run only on designated nodes,
17591742
improving resource utilization and isolation. This change will include:
@@ -1763,8 +1746,7 @@ def _version_specific_upgrade(
17631746
17641747
If you prefer not to use node taints, you can opt out by adding `taints: []`
17651748
to each node group definition in your nebari-config.yaml file.
1766-
"""
1767-
)
1749+
""")
17681750
rich.print(text)
17691751

17701752
provider_full_name = provider_enum_name_map.get(provider)

tests/tests_unit/test_cli_keycloak.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,15 @@ def parse_yaml(stdout_str: str, headers: list):
124124

125125

126126
def test_parse_table():
127-
table_str = dedent(
128-
""" Keycloak Users (Count: 3)
127+
table_str = dedent(""" Keycloak Users (Count: 3)
129128
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━┓
130129
┃ Username ┃ Email ┃ Groups ┃
131130
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━┩
132131
│ test-dev │ test-dev@example.com │ ['analyst', 'developer'] │
133132
│ test-admin │ test-admin@example.com │ ['admin'] │
134133
│ test-nogroup │ test-nogroup@example.com │ [] │
135134
└──────────────┴──────────────────────────┴──────────────────────────┘
136-
"""
137-
)
135+
""")
138136
expected = [
139137
{
140138
"username": "test-dev",
@@ -160,14 +158,12 @@ def test_parse_table():
160158

161159

162160
def test_parse_yaml():
163-
yaml_str = dedent(
164-
"""
161+
yaml_str = dedent("""
165162
- name: test
166163
roles:
167164
- allow-test-to-pass
168165
- other-role
169-
"""
170-
)
166+
""")
171167
expected = [
172168
{
173169
"name": "test",

tests/tests_unit/test_cli_upgrade.py

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ def test_cli_upgrade_image_tags(monkeypatch: pytest.MonkeyPatch):
173173
end_version,
174174
# # number of "y" inputs directly corresponds to how many matching images are found in yaml
175175
inputs=["y", "y", "y", "y", "y", "y", "y"],
176-
addl_config=yaml.safe_load(
177-
f"""
176+
addl_config=yaml.safe_load(f"""
178177
default_images:
179178
jupyterhub: quay.io/nebari/nebari-jupyterhub:{start_version}
180179
jupyterlab: quay.io/nebari/nebari-jupyterlab:{start_version}
@@ -196,8 +195,7 @@ def test_cli_upgrade_image_tags(monkeypatch: pytest.MonkeyPatch):
196195
dask_worker:
197196
test:
198197
image: quay.io/nebari/nebari-dask-worker:{start_version}
199-
"""
200-
),
198+
"""),
201199
)
202200

203201
for _, v in upgraded["default_images"].items():
@@ -240,15 +238,13 @@ def test_cli_upgrade_fail_on_downgrade():
240238
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
241239
assert tmp_file.exists() is False
242240

243-
nebari_config = yaml.safe_load(
244-
f"""
241+
nebari_config = yaml.safe_load(f"""
245242
project_name: test
246243
provider: local
247244
domain: test.example.com
248245
namespace: dev
249246
nebari_version: {start_version}
250-
"""
251-
)
247+
""")
252248

253249
with open(tmp_file.resolve(), "w") as f:
254250
yaml.dump(nebari_config, f)
@@ -279,15 +275,13 @@ def test_cli_upgrade_does_nothing_on_same_version():
279275
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
280276
assert tmp_file.exists() is False
281277

282-
nebari_config = yaml.safe_load(
283-
f"""
278+
nebari_config = yaml.safe_load(f"""
284279
project_name: test
285280
provider: local
286281
domain: test.example.com
287282
namespace: dev
288283
nebari_version: {start_version}
289-
"""
290-
)
284+
""")
291285

292286
with open(tmp_file.resolve(), "w") as f:
293287
yaml.dump(nebari_config, f)
@@ -323,8 +317,7 @@ def callback(tmp_file: Path, _result: Any):
323317
start_version,
324318
end_version,
325319
addl_args=["--attempt-fixes"],
326-
addl_config=yaml.safe_load(
327-
"""
320+
addl_config=yaml.safe_load("""
328321
security:
329322
authentication:
330323
type: custom
@@ -338,8 +331,7 @@ def callback(tmp_file: Path, _result: Any):
338331
default_images:
339332
conda_store: ""
340333
dask_gateway: ""
341-
"""
342-
),
334+
"""),
343335
callback=callback,
344336
)
345337

@@ -361,8 +353,7 @@ def test_cli_upgrade_to_0_4_0_fails_for_custom_auth_without_attempt_fixes():
361353
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
362354
assert tmp_file.exists() is False
363355

364-
nebari_config = yaml.safe_load(
365-
f"""
356+
nebari_config = yaml.safe_load(f"""
366357
project_name: test
367358
provider: local
368359
domain: test.example.com
@@ -371,8 +362,7 @@ def test_cli_upgrade_to_0_4_0_fails_for_custom_auth_without_attempt_fixes():
371362
security:
372363
authentication:
373364
type: custom
374-
"""
375-
)
365+
""")
376366

377367
with open(tmp_file.resolve(), "w") as f:
378368
yaml.dump(nebari_config, f)
@@ -399,14 +389,12 @@ def test_cli_upgrade_to_2023_10_1_cdsdashboard_removed(monkeypatch: pytest.Monke
399389
start_version = "2023.7.2"
400390
end_version = "2023.10.1"
401391

402-
addl_config = yaml.safe_load(
403-
"""
392+
addl_config = yaml.safe_load("""
404393
cdsdashboards:
405394
enabled: true
406395
cds_hide_user_named_servers: true
407396
cds_hide_user_dashboard_servers: false
408-
"""
409-
)
397+
""")
410398

411399
upgraded = assert_nebari_upgrade_success(
412400
monkeypatch,
@@ -473,8 +461,7 @@ def mock_input_ask(prompt, *args, **kwargs):
473461
tmp_file = Path(tmp).resolve() / "nebari-config.yaml"
474462
assert tmp_file.exists() is False
475463

476-
nebari_config = yaml.safe_load(
477-
f"""
464+
nebari_config = yaml.safe_load(f"""
478465
project_name: test
479466
provider: {provider}
480467
domain: test.example.com
@@ -487,8 +474,7 @@ def mock_input_ask(prompt, *args, **kwargs):
487474
{get_provider_config_block_name(provider)}:
488475
region: {MOCK_CLOUD_REGIONS.get(provider, {})[0]}
489476
kubernetes_version: {kubernetes_configs[provider][k8s_status]}
490-
"""
491-
)
477+
""")
492478
with open(tmp_file.resolve(), "w") as f:
493479
yaml.dump(nebari_config, f)
494480

@@ -543,15 +529,13 @@ def assert_nebari_upgrade_success(
543529

544530
# merge basic config with any test case specific values provided
545531
nebari_config = {
546-
**yaml.safe_load(
547-
f"""
532+
**yaml.safe_load(f"""
548533
project_name: test
549534
provider: {provider}
550535
domain: test.example.com
551536
namespace: dev
552537
nebari_version: {start_version}
553-
"""
554-
),
538+
"""),
555539
**addl_config,
556540
}
557541

0 commit comments

Comments
 (0)