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

Pickling: respawning #572

Closed
wants to merge 15 commits into from
Closed

Conversation

thenno
Copy link
Contributor

@thenno thenno commented May 3, 2024

resolves #558

@Kontakter Kontakter requested review from Kontakter and denvr May 6, 2024 11:17
@Kontakter Kontakter added the SDK SDK related label May 6, 2024
def run(self):
command = self.make_command()
logger.info("Start respawn in docker")
logger.info("Command: " + " ".join(command))
Copy link
Collaborator

@Kontakter Kontakter May 7, 2024

Choose a reason for hiding this comment

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

Let merge this message with previous one:

logger.info("Respawn in docker (command: ...)")

yt/python/yt/wrapper/py_wrapper.py Show resolved Hide resolved
stdout=sys.stdout,
stderr=sys.stderr,
bufsize=1,
universal_newlines=True,
Copy link
Collaborator

Choose a reason for hiding this comment

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

What the idea is behind specifying these options?

bufsize=1,
universal_newlines=True,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an old artifact from the time I tried to process stdout/stderr.
I'll just delete it.

self._env = {
key: value
for key, value in os.environ.items()
if key.startswith('YT_')
Copy link
Collaborator

Choose a reason for hiding this comment

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

We usually use double quotes

yt/python/yt/wrapper/py_wrapper.py Show resolved Hide resolved
self._main_script_path = main_scipt_path if main_scipt_path is not None else os.path.abspath(sys.argv[0])
self._cwd = cwd if cwd is not None else os.path.abspath(os.getcwd())
self._homedir = homedir if homedir is not None else os.path.expanduser("~")
# we need to provide all python libraries to a container to ensure picking works
Copy link
Collaborator

Choose a reason for hiding this comment

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

pickLing


def _make_docker_env_args(self, env):
return list(itertools.chain(*[
("-e", "{0}={1}".format(key, value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let use chain.from_iterable here and in other similar situations.


def _make_docker_env_args(self, env):
return list(itertools.chain(*[
("-e", "{0}={1}".format(key, value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it safe to pass env variables as "{0}={1}"? What if it contains white space or some other special characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a very good point.
There is a similar problem not only with environment variables, but also with other values (e.g. mount points).

So I'll add escaping for the generated command.

return self._mount
# if we mount the entire local file system in docker under an arbitrary name
# we will break the symlinks,
# so we have to find only the paths necessary for work and mount them along the same paths
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let fix style of comment

]))

def _make_mount_paths(self):
# use user provided values
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let drop this comment, in my opinion it gives no additional information that is not expressed in the code

@thenno thenno force-pushed the respawn_wrapper_in_docker branch from 31e5a33 to 95cfd8c Compare May 7, 2024 14:37
Copy link

robot-magpie bot commented May 8, 2024

@Kontakter has imported your pull request. If you are a Yandex employee, you can view this diff.



@authors("thenno")
def test_docker_respawner(monkeypatch):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let add pytest.skip() for case of ya make


from .conftest import authors

from yt.wrapper.py_wrapper import DockerRespawner, respawn_in_docker
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let use import from yt.wrapper

"-e", "YT_BASE_LAYER=some_image",
"-v", "/home/user:/home/user", # user's homedir
"-v", "/home/user2/yt:/home/user2/yt", # main script's dir
"-v", "/root:/root", # current cwd
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let here (and in other places in this file) fix the comments:

  • Write it on the previous line.
  • Write it as # Specifying user's homedir.

"-v", "/home/user:/home/user", # user's homedir
"-v", "/home/user2/yt:/home/user2/yt", # main script's dir
"-v", "/root:/root", # current cwd
# a part of pythonpython outside homedir
Copy link
Collaborator

Choose a reason for hiding this comment

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

pythonpython?

Copy link
Collaborator

@Kontakter Kontakter left a comment

Choose a reason for hiding this comment

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

See comments above

Copy link

robot-magpie bot commented May 8, 2024

@Kontakter has imported your pull request. If you are a Yandex employee, you can view this diff.

Copy link

robot-magpie bot commented May 13, 2024

✅ This pull request is being closed because it has been successfully merged.

@robot-magpie robot-magpie bot closed this May 13, 2024
robot-piglet pushed a commit that referenced this pull request May 13, 2024
resolves #558

---
938e34fa99423f85bb4a7ad055efe338ae7949a7

Pull Request resolved: #572
dmi-feo pushed a commit to dmi-feo/ytsaurus that referenced this pull request May 14, 2024
resolves ytsaurus#558

---
938e34fa99423f85bb4a7ad055efe338ae7949a7

Pull Request resolved: ytsaurus#572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK SDK related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pickling: respawning
2 participants