Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
polyaxon-ci committed Jan 4, 2025
1 parent 79233a5 commit 5eb1a36
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 45 deletions.
2 changes: 1 addition & 1 deletion haupt/haupt/apis/bookmarks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def destroy(self, request, *args, **kwargs):
Models.Bookmark,
**user_filter,
content_type__model=self.content_type,
object_id=obj.id
object_id=obj.id,
)
bookmark.enabled = False
bookmark.save(update_fields=["enabled"])
Expand Down
4 changes: 2 additions & 2 deletions haupt/haupt/apis/runs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def clone(self, obj, content, **kwargs):
description=kwargs.get("description"),
tags=kwargs.get("tags"),
meta_info=kwargs.get("meta_info"),
**self._get_additional_fields(obj)
**self._get_additional_fields(obj),
)


Expand All @@ -138,7 +138,7 @@ def clone(self, obj, content, **kwargs):
tags=kwargs.get("tags"),
meta_info=kwargs.get("meta_info"),
message="Run was resumed by user.",
**self._get_additional_fields(obj)
**self._get_additional_fields(obj),
)

def pre_validate(self, obj):
Expand Down
2 changes: 0 additions & 2 deletions haupt/haupt/cli/sandbox.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

import click

from polyaxon.logger import clean_outputs
Expand Down
2 changes: 0 additions & 2 deletions haupt/haupt/cli/viewer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

from collections.abc import Mapping
from typing import Dict, Optional

Expand Down
4 changes: 0 additions & 4 deletions haupt/haupt/common/apis/urls/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
RUN_UUID_PATTERN,
)

URLS_RUNS_CREATE = r"^{}/{}/runs/create/?$".format(
OWNER_NAME_PATTERN, PROJECT_NAME_PATTERN
)
URLS_RUNS_LIST = r"^{}/runs/list/?$".format(OWNER_NAME_PATTERN, PROJECT_NAME_PATTERN)
URLS_RUNS_DETAILS = r"^{}/{}/runs/{}/?$".format(
OWNER_NAME_PATTERN, PROJECT_NAME_PATTERN, RUN_UUID_PATTERN
)
Expand Down
4 changes: 3 additions & 1 deletion haupt/haupt/common/authentication/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ def authenticate(
return self.authenticate_credentials(internal_service, token)

def authenticate_credentials(
self, service: str, key: str # pylint:disable=arguments-differ
self,
service: str,
key: str, # pylint:disable=arguments-differ
) -> Optional[Tuple["InternalUser", None]]:
internal_user = InternalUser(service=service)
if internal_user.access_token != key:
Expand Down
2 changes: 1 addition & 1 deletion haupt/haupt/common/endpoints/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, *args, as_attachment=False, filepath="", **kwargs):
as_attachment=as_attachment,
filename=filename,
headers=headers,
**kwargs
**kwargs,
)

def get_stat_headers(self, filepath: str) -> Optional[Dict]:
Expand Down
4 changes: 2 additions & 2 deletions haupt/haupt/common/events/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(
instance_uuid: Optional[str] = None,
ref_id: Optional[str] = None,
event_data: Mapping = None,
**items
**items,
):
self.uuid = UUID(uid) if uid else uuid1()
self.datetime = datetime or timezone.now()
Expand Down Expand Up @@ -250,7 +250,7 @@ def from_event_data(cls, event_data: Mapping, **kwargs) -> "Event":
instance=event_data.get("instance"),
instance_id=event_data.get("instance_id"),
instance_uuid=event_data.get("instance_uuid"),
**kwargs
**kwargs,
)


Expand Down
4 changes: 2 additions & 2 deletions haupt/haupt/common/events/event_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_event(
event_type: str,
event_data: Mapping = None,
instance: Any = None,
**kwargs
**kwargs,
) -> Event:
if instance or not event_data:
return self.event_manager.get(event_type).from_instance(instance, **kwargs)
Expand All @@ -30,7 +30,7 @@ def record(
event_type: str,
event_data: Mapping = None,
instance: Any = None,
**kwargs
**kwargs,
) -> Optional[Event]:
"""Validate and record an event.
Expand Down
24 changes: 6 additions & 18 deletions haupt/haupt/orchestration/executor/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ def handle_run_created(cls, workers_backend, event: "Event") -> None: # noqa: F
)

@classmethod
def handle_run_approved_triggered(
cls, workers_backend, event: "Event"
) -> None: # noqa: F821
def handle_run_approved_triggered(cls, workers_backend, event: "Event") -> None: # noqa: F821
run = cls.MANAGER.get_run(run_id=event.instance_id, run=event.instance)
if not run:
return
Expand All @@ -101,21 +99,15 @@ def handle_run_approved_triggered(
)

@classmethod
def handle_run_stopped_triggered(
cls, workers_backend, event: "Event"
) -> None: # noqa: F821
def handle_run_stopped_triggered(cls, workers_backend, event: "Event") -> None: # noqa: F821
cls.MANAGER.runs_stop(run_id=event.instance_id, run=event.instance)

@classmethod
def handle_run_skipped_triggered(
cls, workers_backend, event: "Event"
) -> None: # noqa: F821
def handle_run_skipped_triggered(cls, workers_backend, event: "Event") -> None: # noqa: F821
cls.MANAGER.runs_skip(run_id=event.instance_id, run=event.instance)

@classmethod
def handle_run_done(
cls, workers_backend, event: "Event" = None
) -> None: # noqa: F821
def handle_run_done(cls, workers_backend, event: "Event" = None) -> None: # noqa: F821
"""Handles all run done statuses"""
workers_backend.send(
SchedulerCeleryTasks.RUNS_NOTIFY_DONE,
Expand All @@ -125,9 +117,7 @@ def handle_run_done(
)

@classmethod
def handle_run_new_status(
cls, workers_backend, event: "Event"
) -> None: # noqa: F821
def handle_run_new_status(cls, workers_backend, event: "Event") -> None: # noqa: F821
run = cls.MANAGER.get_run(run_id=event.instance_id, run=event.instance)
if not run:
return
Expand All @@ -143,9 +133,7 @@ def handle_run_new_status(
)

@classmethod
def handle_new_artifacts(
cls, workers_backend, event: "Event"
) -> None: # noqa: F821
def handle_new_artifacts(cls, workers_backend, event: "Event") -> None: # noqa: F821
artifacts = event.data.get("artifacts")
if not artifacts:
return
Expand Down
5 changes: 3 additions & 2 deletions haupt/haupt/orchestration/scheduler/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1628,8 +1628,9 @@ def _get_project_version_refs(
# }
if len(ids) != len(names):
raise AccessNotFound(
"Some {} version refs were provided "
"but were not found: `{}`".format(kind, names)
"Some {} version refs were provided but were not found: `{}`".format(
kind, names
)
)

# if (
Expand Down
1 change: 1 addition & 0 deletions haupt/haupt/polyconf/asgi/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
"""

import logging
import os

Expand Down
1 change: 1 addition & 0 deletions haupt/haupt/polyconf/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1428,13 +1428,13 @@ def test_get_runs_for_original(self):
assert resp.data["next"] is None
assert resp.data["count"] == 2

resp = self.client.get(self.url + f"?query=cloning_kind:cache")
resp = self.client.get(self.url + "?query=cloning_kind:cache")
assert resp.status_code == status.HTTP_200_OK

assert resp.data["next"] is None
assert resp.data["count"] == 1

resp = self.client.get(self.url + f"?query=cloning_kind:cache")
resp = self.client.get(self.url + "?query=cloning_kind:cache")
assert resp.status_code == status.HTTP_200_OK

assert resp.data["next"] is None
Expand Down
1 change: 0 additions & 1 deletion haupt/tests/test_apis/test_projects/test_views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from flaky import flaky
from mock.mock import patch

from rest_framework import status

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ def test_get_filter(self): # pylint:disable=too-many-statements
assert resp.data["count"] == 0

# Values
resp = self.client.get(self.url + f"?query=cloning_kind:restart")
resp = self.client.get(self.url + "?query=cloning_kind:restart")
assert resp.status_code == status.HTTP_200_OK
assert resp.data["next"] is None
assert resp.data["count"] == 1

resp = self.client.get(self.url + f"?query=cloning_kind:copy")
resp = self.client.get(self.url + "?query=cloning_kind:copy")
assert resp.status_code == status.HTTP_200_OK
assert resp.data["next"] is None
assert resp.data["count"] == 1

resp = self.client.get(self.url + f"?query=cloning_kind:cache")
resp = self.client.get(self.url + "?query=cloning_kind:cache")
assert resp.status_code == status.HTTP_200_OK
assert resp.data["next"] is None
assert resp.data["count"] == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ def test_get_filter(self): # pylint:disable=too-many-statements
assert resp.data["count"] == 0

# Values
resp = self.client.get(self.url + f"?query=values.foo:bar")
resp = self.client.get(self.url + "?query=values.foo:bar")
assert resp.status_code == status.HTTP_200_OK
assert resp.data["next"] is None
assert resp.data["count"] == 4

resp = self.client.get(self.url + f"?query=values.foo:moo")
resp = self.client.get(self.url + "?query=values.foo:moo")
assert resp.status_code == status.HTTP_200_OK
assert resp.data["next"] is None
assert resp.data["count"] == 0
Expand Down

0 comments on commit 5eb1a36

Please sign in to comment.