flytekit.interactive.vscode_lib.decorator
0.1.dev2192+g7c539c3.d20250403
flytekit.interactive.vscode_lib.decorator
Class
Description
vscode
Abstract class for class decorators.
Property
Type
Description
EXECUTABLE_NAME
str
EXIT_CODE_SUCCESS
int
HEARTBEAT_PATH
str
INTERACTIVE_DEBUGGING_FILE_NAME
str
MAX_IDLE_SECONDS
int
RESUME_TASK_FILE_NAME
str
TASK_FUNCTION_SOURCE_PATH
str
VSCODE_TYPE_VALUE
str
def download_file (
url,
target_dir: typing. Optional[str],
)
Download a file from a given URL using fsspec.
Parameter
Type
url
target_dir
typing.Optional[str]
def download_vscode (
config: flytekit. interactive. vscode_lib. config. VscodeConfig,
)
Download vscode server and extension from remote to local and add the directory of binary executable to $PATH.
Parameter
Type
config
flytekit.interactive.vscode_lib.config.VscodeConfig
def exit_handler (
child_process: multiprocessing. context. Process,
task_function,
args,
kwargs,
max_idle_seconds: int,
post_execute: typing. Optional[typing. Callable],
)
Check the modified time of ~/.local/share/code-server/heartbeat.
If it is older than max_idle_second seconds, kill the container.
Otherwise, check again every HEARTBEAT_CHECK_SECONDS.
Wait for user to resume the task. If resume_task is set, terminate the VSCode server, reload the task function, and run it with the input of the task.
Parameter
Type
child_process
multiprocessing.context.Process
task_function
args
*args
kwargs
**kwargs
max_idle_seconds
int
post_execute
typing.Optional[typing.Callable]
def get_code_server_info (
code_server_info_dict: dict,
) -> str
Returns the code server information based on the system’s architecture.
This function checks the system’s architecture and returns the corresponding
code server information from the provided dictionary. The function currently
supports AMD64 and ARM64 architectures.
Parameter
Type
code_server_info_dict
dict
def get_installed_extensions ()
Get the list of installed extensions.
Returns:
List[str]: The list of installed extensions.
def is_extension_installed (
extension: str,
installed_extensions: typing. List[str],
) -> bool
Parameter
Type
extension
str
installed_extensions
typing.List[str]
def prepare_interactive_python (
task_function,
)
Copy the original task file to the context working directory. This ensures that the inputs.pb can be loaded, as loading requires the original task interface.
By doing so, even if users change the task interface in their code, we can use the copied task file to load the inputs as native Python objects.
Generate a Python script and a launch.json for users to debug interactively.
Parameter
Type
task_function
def prepare_launch_json ()
Generate the launch.json and settings.json for users to easily launch interactive debugging and task resumption.
def prepare_resume_task_python (
pid: int,
)
Generate a Python script for users to resume the task.
Abstract class for class decorators.
We can attach config on the decorator class and use it in the upper level.
class vscode (
task_function: typing. Optional[typing. Callable],
max_idle_seconds: typing. Optional[int],
port: int,
enable: bool,
run_task_first: bool,
pre_execute: typing. Optional[typing. Callable],
post_execute: typing. Optional[typing. Callable],
config: typing. Optional[flytekit. interactive. vscode_lib. config. VscodeConfig],
)
vscode decorator modifies a container to run a VSCode server:
Overrides the user function with a VSCode setup function.
Download vscode server and extension from remote to local.
Prepare the interactive debugging Python script and launch.json.
Prepare task resumption script.
Launches and monitors the VSCode server.
Register signal handler for task resumption.
Terminates if the server is idle for a set duration or user trigger task resumption.
Parameter
Type
task_function
typing.Optional[typing.Callable]
max_idle_seconds
typing.Optional[int]
port
int
enable
bool
run_task_first
bool
pre_execute
typing.Optional[typing.Callable]
post_execute
typing.Optional[typing.Callable]
config
typing.Optional[flytekit.interactive.vscode_lib.config.VscodeConfig]
Method
Description
execute()
This method will be called when the decorated function is called.
get_extra_config()
Get the config of the decorator.
def execute (
args,
kwargs,
)
This method will be called when the decorated function is called.
Parameter
Type
args
*args
kwargs
**kwargs
Get the config of the decorator.