mirror of
https://github.com/clearml/clearml
synced 2025-04-24 16:26:35 +00:00
Fix browser_login()
when 3rd party cookies are disabled
This commit is contained in:
parent
1dd98ecf8d
commit
9b9c81afec
@ -34,6 +34,7 @@ from .defs import (
|
|||||||
from .request import Request, BatchRequest # noqa: F401
|
from .request import Request, BatchRequest # noqa: F401
|
||||||
from .token_manager import TokenManager
|
from .token_manager import TokenManager
|
||||||
from ..utils import get_http_session_with_retry, urllib_log_warning_setup
|
from ..utils import get_http_session_with_retry, urllib_log_warning_setup
|
||||||
|
from ...backend_config.defs import get_config_file
|
||||||
from ...debugging import get_logger
|
from ...debugging import get_logger
|
||||||
from ...debugging.log import resolve_logging_level
|
from ...debugging.log import resolve_logging_level
|
||||||
from ...utilities.pyhocon import ConfigTree, ConfigFactory
|
from ...utilities.pyhocon import ConfigTree, ConfigFactory
|
||||||
@ -943,11 +944,43 @@ def browser_login(clearml_server=None):
|
|||||||
"or create a free account at {}\n".format(clearml_app_server)
|
"or create a free account at {}\n".format(clearml_app_server)
|
||||||
)
|
)
|
||||||
print("Please login to {} , then press [Enter] to connect ".format(clearml_app_server), end="")
|
print("Please login to {} , then press [Enter] to connect ".format(clearml_app_server), end="")
|
||||||
else:
|
input()
|
||||||
|
elif counter < 1:
|
||||||
print("Oh no we failed to connect \N{worried face}, "
|
print("Oh no we failed to connect \N{worried face}, "
|
||||||
"try to logout and login again - Press [Enter] to retry ", end="")
|
"try to logout and login again - Press [Enter] to retry ", end="")
|
||||||
|
input()
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"\n"
|
||||||
|
"We cannot connect automatically (adblocker / incognito?) \N{worried face} \n"
|
||||||
|
"Please go to {}/settings/workspace-configuration \n"
|
||||||
|
"Then press \x1B[1m\x1B[48;2;26;30;44m\x1B[37m + Create new credentials \x1b[0m \n"
|
||||||
|
"And copy/paste your \x1B[1m\x1B[4mAccess Key\x1b[0m here: ".format(
|
||||||
|
clearml_app_server.lstrip("/")), end="")
|
||||||
|
|
||||||
|
creds = input()
|
||||||
|
if creds:
|
||||||
|
print(" Setting access key ")
|
||||||
|
ENV_ACCESS_KEY.set(creds.strip())
|
||||||
|
|
||||||
|
print("Now copy/paste your \x1B[1m\x1B[4mSecret Key\x1b[0m here: ", end="")
|
||||||
|
creds = input()
|
||||||
|
if creds:
|
||||||
|
print(" Setting secret key ")
|
||||||
|
ENV_SECRET_KEY.set(creds.strip())
|
||||||
|
|
||||||
|
if ENV_ACCESS_KEY.get() and ENV_SECRET_KEY.get():
|
||||||
|
# store in conf file for persistence in runtime
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
with open(get_config_file(), "wt") as f:
|
||||||
|
f.write("api.credentials.access_key={}\napi.credentials.secret_key={}\n".format(
|
||||||
|
ENV_ACCESS_KEY.get(), ENV_SECRET_KEY.get()
|
||||||
|
))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
break
|
||||||
|
|
||||||
input()
|
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
@ -959,6 +992,8 @@ def browser_login(clearml_server=None):
|
|||||||
if token:
|
if token:
|
||||||
# set Token
|
# set Token
|
||||||
ENV_AUTH_TOKEN.set(token)
|
ENV_AUTH_TOKEN.set(token)
|
||||||
|
|
||||||
|
if token or (ENV_ACCESS_KEY.get() and ENV_SECRET_KEY.get()):
|
||||||
# verify token
|
# verify token
|
||||||
Session()
|
Session()
|
||||||
# success
|
# success
|
||||||
|
@ -681,7 +681,9 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
"""
|
"""
|
||||||
if hasattr(tasks, 'CompletedRequest') and callable(tasks.CompletedRequest):
|
if hasattr(tasks, 'CompletedRequest') and callable(tasks.CompletedRequest):
|
||||||
return self.send(
|
return self.send(
|
||||||
tasks.CompletedRequest(self.id, status_reason='completed', status_message=status_message, force=force),
|
tasks.CompletedRequest(
|
||||||
|
self.id, status_reason='completed', status_message=status_message, force=force,
|
||||||
|
publish=True if self._get_runtime_properties().get("_publish_on_complete") else False),
|
||||||
ignore_errors=ignore_errors
|
ignore_errors=ignore_errors
|
||||||
)
|
)
|
||||||
return self.send(
|
return self.send(
|
||||||
@ -707,6 +709,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
assert isinstance(resp.response, tasks.PublishResponse)
|
assert isinstance(resp.response, tasks.PublishResponse)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
def publish_on_completion(self, enable=True):
|
||||||
|
# type: (bool) -> ()
|
||||||
|
""" The signal that this task will be published automatically on task completion """
|
||||||
|
self._set_runtime_properties(runtime_properties={"_publish_on_complete": enable})
|
||||||
|
|
||||||
def _delete(
|
def _delete(
|
||||||
self,
|
self,
|
||||||
delete_artifacts_and_models=True,
|
delete_artifacts_and_models=True,
|
||||||
@ -2154,7 +2161,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
|
|
||||||
Notice: Must be called before `Task.init` !
|
Notice: Must be called before `Task.init` !
|
||||||
|
|
||||||
:param force: Set force using `pip freeze` flag on/off
|
:param force: Set force storing the main python file as a single standalone script
|
||||||
"""
|
"""
|
||||||
cls._force_store_standalone_script = bool(force)
|
cls._force_store_standalone_script = bool(force)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user