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

fix(sdk): add support for service running in a pex based environment #4440

Merged
merged 21 commits into from Nov 10, 2022

Conversation

kptkin
Copy link
Contributor

@kptkin kptkin commented Nov 4, 2022

Fixes WB-11018

Description

What does the PR do?

Based on this discussion in the pex repo: pex-tool/pex#626 (comment) it seems that the correct way to use an executable when running with pex is the use the sys.argv and based on this PR the way to find out if you are in a pex environment is based on this environment variable: pex-tool/pex#1495

Testing

How was this PR tested?

Checklist

  • Include reference to internal ticket "Fixes WB-NNNN" and/or GitHub issue "Fixes #NNNN" (if applicable)
  • Ensure PR title compliance with the conventional commits standards

@kptkin kptkin changed the title fix pex fix(sdk): add support for service running in a pex based environment Nov 4, 2022
@github-actions github-actions bot added the cc-fix label Nov 4, 2022
@codecov
Copy link

codecov bot commented Nov 4, 2022

Codecov Report

Merging #4440 (be2aa92) into main (eddc2ac) will increase coverage by 0.00%.
The diff coverage is 90.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4440   +/-   ##
=======================================
  Coverage   83.03%   83.03%           
=======================================
  Files         258      258           
  Lines       32870    32875    +5     
=======================================
+ Hits        27292    27299    +7     
+ Misses       5578     5576    -2     
Flag Coverage Δ
functest 56.88% <90.00%> (+0.01%) ⬆️
unittest 73.16% <90.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
wandb/sdk/wandb_settings.py 94.45% <75.00%> (-0.12%) ⬇️
wandb/sdk/internal/settings_static.py 93.84% <100.00%> (+0.09%) ⬆️
wandb/sdk/service/service.py 89.28% <100.00%> (+0.12%) ⬆️
wandb/sdk/wandb_manager.py 94.07% <100.00%> (ø)
wandb/sdk/lib/git.py 79.01% <0.00%> (-0.62%) ⬇️
wandb/sdk/wandb_run.py 90.73% <0.00%> (-0.24%) ⬇️
wandb/cli/cli.py 69.20% <0.00%> (+0.09%) ⬆️
wandb/integration/tensorboard/monkeypatch.py 92.59% <0.00%> (+2.46%) ⬆️
wandb/sdk/internal/system/system_info.py 91.55% <0.00%> (+3.24%) ⬆️

@github-actions github-actions bot added cc-fix and removed cc-fix labels Nov 4, 2022
@github-actions github-actions bot added cc-fix and removed cc-fix labels Nov 7, 2022
Copy link
Contributor

@vanpelt vanpelt left a comment

Choose a reason for hiding this comment

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

Nice

# one special case here is running inside a PEX environment,
# see https://pex.readthedocs.io/en/latest/index.html for more info about PEX
settings["_executable"] = (
self._executable or os.environ.get("PEX") or sys.executable
Copy link
Contributor

Choose a reason for hiding this comment

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

I was just looking at the official docs and sys.executable can return empty string or None. I imagine it makes more sense to fall back to "python" as the executable if we can't get an absolute path...

@@ -82,7 +85,8 @@ def _launch_server(self) -> None:
fname = os.path.join(tmpdir, f"port-{pid}.txt")

pid_str = str(os.getpid())
exec_cmd_list = [sys.executable, "-m"]
executable = self._python_executable or sys.executable
Copy link
Contributor

Choose a reason for hiding this comment

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

I think or "python" would be reasonable here. There are other places in the codebase where we assume sys.executable will be a python interpreter that we should fix as well so maybe a util / helper is appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah good catch, will do!

@kptkin kptkin marked this pull request as ready for review November 8, 2022 23:51
@kptkin kptkin added this to the sdk-2022-12.1 milestone Nov 8, 2022
@kptkin kptkin merged commit ff6cb35 into main Nov 10, 2022
@kptkin kptkin deleted the WB-11018 branch November 10, 2022 03:57
andrewtruong pushed a commit that referenced this pull request Dec 2, 2022
…4440)

* fix pex

* python_executable -> settings

* add a test

* fix(sdk): pex pex pex

* fix config

* oomny v goroo ne poidyot

* oomny v goroo ne poidyot

* oora my lomim gnutsya shvedy

* oora my lomim gnutsya shvedy

* oora my lomim gnutsya shvedy

* oora my lomim gnutsya shvedy

* oora my lomim gnutsya shvedy

* oora my lomim gnutsya shvedy

* replace borky yea test with a (borky) circle job

* clean up

* lint

Co-authored-by: Dmitry Duev <dima@wandb.com>
Co-authored-by: Dmitry Duev <dmitryduev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants