Skip to content

local-dev: pull images on every run + add support for tty resizing#200

Merged
ayushkamat merged 6 commits intomainfrom
ayush/local-dev
Nov 23, 2022
Merged

local-dev: pull images on every run + add support for tty resizing#200
ayushkamat merged 6 commits intomainfrom
ayush/local-dev

Conversation

@ayushkamat
Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: Ayush Kamat <ayush@latch.bio>
Signed-off-by: Ayush Kamat <ayush@latch.bio>
Signed-off-by: Ayush Kamat <ayush@latch.bio>
Signed-off-by: Ayush Kamat <ayush@latch.bio>

wf_name = ""
for entity in FlyteEntities.entities:
if isinstance(entity, PythonFunctionWorkflow):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if multiple workflows are defined in the package

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they would all have the same version, so not an issue

resp.raise_for_status()
latest_version = resp.json()["version"]

return f"{config.dkr_repo}/{current_workspace()}_{pkg_root.name}:{latest_version}"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we really need to not make the name of the workflow container depend on the name of the directory

think it should be more like git, where project directory name has nothing to do with repository name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can add it to the backlog lol

Comment thread latch_cli/services/local_dev.py Outdated
async def send_message(
ws: websockets.WebSocketClientProtocol,
message: Union[str, bytes],
typ: Optional[str] = None,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

making this into an optional enum would make things more legible, its unclear to me what values are allowed and therefore where things might break

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call

raise EOFError

if not COMMAND_EXPRESSION.match(cmd):
await aioconsole.aprint("Invalid command")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parsing out useful errors from a failed match would be instructive here (eg. run-scripts vs run-script often trips me up)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also a good call

continue

if (
cmd.startswith("run")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should actually be able to include arbitrary whitespace characters before your first command and still get desired behavior (try with bash)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread latch_cli/services/local_dev.py Outdated
EXEC_COMMANDS = ["shell", "run", "run-script"]
LIST_COMMANDS = ["ls", "list-tasks"]

COMMAND_EXPRESSION = re.compile("^(run\s.+|run-script\s.+|shell|list-tasks|ls.*)$")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should actually be able to include arbitrary whitespace characters before your first command and still get desired behavior (try with bash)

resize_event_queue = asyncio.Queue()

def new_sigwinch_handler(signum, frame):
if isinstance(old_sigwinch_handler, Callable):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would handle the cases when you dont get a callable

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i also remember there is a builtin to do this - https://docs.python.org/3/library/functions.html#callable, but i actually can't think of why this is better

i'm pretty sure isinstance(obj, Callable) iff obj has __call__ which is exactly what builtin does, literally cant find anything else about it

Copy link
Copy Markdown
Contributor Author

@ayushkamat ayushkamat Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the cases where i dont get a callable arent things i need to handle - SIG_IGN is literally ignore the signal in this process, SIG_DFL for the signal im handling here (SIGWINCH) means the current handler does the default action for SIGWINCH, which is also to ignore it (https://www.gnu.org/software/libc/manual/html_node/Miscellaneous-Signals.html), and None ofc means that there is no handler for it

Signed-off-by: Ayush Kamat <ayush@latch.bio>
Signed-off-by: Ayush Kamat <ayush@latch.bio>
@ayushkamat ayushkamat merged commit ccb8728 into main Nov 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants