This commit is contained in:
thomas 2022-12-16 08:41:13 +01:00
parent c4b27fb69c
commit 8331e24a3f
2 changed files with 26 additions and 4 deletions

4
.gitignore vendored
View File

@ -110,8 +110,8 @@ celerybeat-schedule
# dotenv # dotenv
.env .env
.env_staging .env.staging
.env_local .env.local
# virtualenv # virtualenv
.venv .venv

View File

@ -124,7 +124,16 @@ class LightningWork:
" in the next version. Use `cache_calls` instead." " in the next version. Use `cache_calls` instead."
) )
self._cache_calls = run_once if run_once is not None else cache_calls self._cache_calls = run_once if run_once is not None else cache_calls
self._state = {"_host", "_port", "_url", "_future_url", "_internal_ip", "_restarting", "_cloud_compute"} self._state = {
"_host",
"_port",
"_url",
"_future_url",
"_internal_ip",
"_restarting",
"_cloud_compute",
"_display_name",
}
self._parallel = parallel self._parallel = parallel
self._host: str = host self._host: str = host
self._port: Optional[int] = port self._port: Optional[int] = port
@ -134,6 +143,7 @@ class LightningWork:
# setattr_replacement is used by the multiprocessing runtime to send the latest changes to the main coordinator # setattr_replacement is used by the multiprocessing runtime to send the latest changes to the main coordinator
self._setattr_replacement: Optional[Callable[[str, Any], None]] = None self._setattr_replacement: Optional[Callable[[str, Any], None]] = None
self._name = "" self._name = ""
self._display_name = ""
# The ``self._calls`` is used to track whether the run # The ``self._calls`` is used to track whether the run
# method with a given set of input arguments has already been called. # method with a given set of input arguments has already been called.
# Example of its usage: # Example of its usage:
@ -208,10 +218,22 @@ class LightningWork:
return name in LightningWork._INTERNAL_STATE_VARS or not name.startswith("_") return name in LightningWork._INTERNAL_STATE_VARS or not name.startswith("_")
@property @property
def name(self): def name(self) -> str:
"""Returns the name of the LightningWork.""" """Returns the name of the LightningWork."""
return self._name return self._name
@property
def display_name(self) -> str:
"""Returns the display name of the LightningWork for the Admin UI in the cloud."""
if self._display_name == "":
return self.name
return self._display_name
@display_name.setter
def display_name(self, display_name: str) -> None:
"""Setter for the display name of the LightningWork."""
self._display_name = display_name
@property @property
def cache_calls(self) -> bool: def cache_calls(self) -> bool:
"""Returns whether the ``run`` method should cache its input arguments and not run again when provided with """Returns whether the ``run`` method should cache its input arguments and not run again when provided with