Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add anonymous beast option #78

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions esd_services_api_client/beast/v2/_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def __init__(
*,
base_url,
code_root="/ecco/dist",
auth: BoxerTokenAuth,
lifecycle_check_interval: int = 60,
failure_type: Optional[Exception] = None,
auth: Optional[BoxerTokenAuth] = None,
):
"""
Creates a Beast connector, capable of submitting/status tracking etc.
Expand All @@ -63,7 +63,8 @@ def __init__(
]
self.success_stages = ["COMPLETED"]
self.http = session_with_retries()
self.http.hooks["response"].append(auth.get_refresh_hook(self.http))
if auth and isinstance(auth, BoxerTokenAuth):
self.http.hooks["response"].append(auth.get_refresh_hook(self.http))
self.http.auth = auth
self._failure_type = failure_type or Exception
self._version = "v2"
Expand All @@ -75,6 +76,23 @@ def version(self):
"""
return self._version

@classmethod
def create_anonymous(
cls,
base_url,
code_root="/ecco/dist",
lifecycle_check_interval: int = 60,
failure_type: Optional[Exception] = None,
) -> "BeastConnector":
"""Creates Beast connector with no authentication.
This should be used within a hosting clusters."""
return cls(
base_url=base_url,
code_root=code_root,
lifecycle_check_interval=lifecycle_check_interval,
failure_type=failure_type,
)

def _submit(self, request: JobRequest) -> (str, str):
request_json = request.to_dict()

Expand Down
22 changes: 20 additions & 2 deletions esd_services_api_client/beast/v3/_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def __init__(
*,
base_url,
code_root="/ecco/dist",
auth: BoxerTokenAuth,
lifecycle_check_interval: int = 60,
auth: Optional[BoxerTokenAuth] = None,
failure_type: Optional[Exception] = None,
):
"""
Expand All @@ -67,7 +67,8 @@ def __init__(
]
self.success_stages = ["COMPLETED"]
self.http = session_with_retries()
self.http.hooks["response"].append(auth.get_refresh_hook(self.http))
if auth and isinstance(auth, BoxerTokenAuth):
self.http.hooks["response"].append(auth.get_refresh_hook(self.http))
self.http.auth = auth
self._failure_type = failure_type or Exception
self._version = "v3"
Expand All @@ -79,6 +80,23 @@ def version(self):
"""
return self._version

@classmethod
def create_anonymous(
cls,
base_url,
code_root="/ecco/dist",
lifecycle_check_interval: int = 60,
failure_type: Optional[Exception] = None,
) -> "BeastConnector":
"""Creates Beast connector with no authentication.
This should be used within a hosting clusters."""
return cls(
base_url=base_url,
code_root=code_root,
lifecycle_check_interval=lifecycle_check_interval,
failure_type=failure_type,
)

def _submit(self, request: JobRequest, spark_job_name: str) -> (str, str):
request_json = request.to_dict()

Expand Down