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

feat(sdk): add infrastructure for roll-out of next generation python client #7641

Draft
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

dmitryduev
Copy link
Member

@dmitryduev dmitryduev commented May 14, 2024

Description

This PR adds infrastructure for the roll-out of the new Go-based python client.

_WANDB_NG=true python
import wandb

s = wandb.Session()
print(s.address)
s.teardown()

with wandb.Session() as s:
    print(s.address)
  • I updated CHANGELOG.md, or it's not applicable

Testing

How was this PR tested?

Copy link

codecov bot commented May 14, 2024

Codecov Report

Attention: Patch coverage is 63.90533% with 61 lines in your changes missing coverage. Please review.

Project coverage is 75.76%. Comparing base (15f4422) to head (cda6fb4).
Report is 57 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7641      +/-   ##
==========================================
+ Coverage   74.29%   75.76%   +1.47%     
==========================================
  Files         500      502       +2     
  Lines       55727    54168    -1559     
==========================================
- Hits        41400    41041     -359     
+ Misses      13918    12718    -1200     
  Partials      409      409              
Flag Coverage Δ
func 41.30% <58.75%> (-0.06%) ⬇️
system 63.43% <63.31%> (-0.08%) ⬇️
unit 56.30% <60.94%> (+0.94%) ⬆️

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

Files Coverage Δ
core/cmd/wandb-core/main.go 71.64% <100.00%> (ø)
core/pkg/filestream/filestreamimpl.go 86.27% <100.00%> (+19.09%) ⬆️
core/pkg/observability/util.go 86.66% <100.00%> (+9.16%) ⬆️
core/pkg/observability/sentry.go 61.81% <50.00%> (+3.84%) ⬆️
wandb/sdk/wandb_init.py 84.02% <50.00%> (-0.16%) ⬇️
wandb/lib/__init__.py 0.00% <0.00%> (ø)
wandb/__init__.py 93.51% <93.39%> (-0.35%) ⬇️
wandb/lib/lib.py 0.00% <0.00%> (ø)

... and 100 files with indirect coverage changes

@dmitryduev dmitryduev changed the title feat(sdk): ng py feat(sdk): add infrastructure for the roll-out of the new Go-based python client May 17, 2024
@dmitryduev dmitryduev changed the title feat(sdk): add infrastructure for the roll-out of the new Go-based python client feat(sdk): add infrastructure for the roll-out python client May 17, 2024
@dmitryduev dmitryduev changed the title feat(sdk): add infrastructure for the roll-out python client feat(sdk): add infrastructure for roll-out of next generation python client May 17, 2024
@dmitryduev dmitryduev marked this pull request as ready for review May 17, 2024 22:35
@dmitryduev dmitryduev requested a review from a team as a code owner May 17, 2024 22:35
client/client.go Outdated Show resolved Hide resolved
client/go.mod Outdated Show resolved Hide resolved
client/hatch.py Show resolved Hide resolved
client/hatch.py Outdated Show resolved Hide resolved
core/pkg/observability/sentry.go Outdated Show resolved Hide resolved
client/pkg/session/session.go Outdated Show resolved Hide resolved

// setupLogger sets up the default logger for the session
func (s *Session) setupLogger() {
if file, _ := observability.GetLoggerPath("client"); file != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

invert if statement to reduce nesting

if x { doLotsOfStuff() } => if !x { return } doLotsOfStuff()

client/pkg/session/session.go Outdated Show resolved Hide resolved
client/pkg/session/session.go Outdated Show resolved Hide resolved
CorePath string
}

// Session manages the lifecycle of a connection session
Copy link
Contributor

Choose a reason for hiding this comment

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

it's not immediately clear to me that this refers to a connection to the wandb-core internal process

Session is a connection to the internal "core" process.

also, maybe it would be more informative to call this InternalProcess instead of Session. Each "session" corresponds to one process, but the naming leaves open the possibility that there could be multiple sessions per process.

Copy link
Member Author

Choose a reason for hiding this comment

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

Elaborated what connection we're referring to in the docstring.

As for the naming, I think Session is more appropriate. We are making it public with the intent to allow Go users to connect to a wandb-core service already running either locally or on the network.

Copy link
Contributor

Choose a reason for hiding this comment

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

the intent to allow Go users to connect to a wandb-core service already running

I see, that makes sense. It has a Start() method that launches a new internal process; I suppose we'd eventually add a Connect() method?

What if a user wants to start a process without connecting to it, with the intention to connect from other processes? It seems there's an opportunity to separate concepts:

  • WandbProcess is a reference to a running process.
    • WandbProcess::Connect() Session opens and returns a connection to the process.
    • WandbProcess::Kill() kills the process.
  • Session is a connection to a running W&B process.
    • Session::Close() closes the connection and frees any resources.
    • Other methods for communicating with the session.

These should be interfaces to make code that uses them testable.

Optionally, we can have WandbProcessLauncher and SessionStarter, but I think we can get away with top-level Launch(settings) WandbProcess and Connect(address) Session functions.

The simplest usage in Go would be:

process := wandb.Launch(...)
defer process.Kill()

session := process.Connect()
defer session.Close()

session.Send(...)

Or to connect to a process running elsewhere:

session := wandb.Connect(...)
defer session.Close()

session.Send(...)

client/cmd/client/main.go Outdated Show resolved Hide resolved
Comment on lines 40 to 41
// internalProcess is the launcher that manages the wandb-core process
internalProcess *launcher.Launcher
Copy link
Contributor

Choose a reason for hiding this comment

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

by the name, this sounds like it would launch the process, not manage it

CorePath string
}

// Session manages the lifecycle of a connection session
Copy link
Contributor

Choose a reason for hiding this comment

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

the intent to allow Go users to connect to a wandb-core service already running

I see, that makes sense. It has a Start() method that launches a new internal process; I suppose we'd eventually add a Connect() method?

What if a user wants to start a process without connecting to it, with the intention to connect from other processes? It seems there's an opportunity to separate concepts:

  • WandbProcess is a reference to a running process.
    • WandbProcess::Connect() Session opens and returns a connection to the process.
    • WandbProcess::Kill() kills the process.
  • Session is a connection to a running W&B process.
    • Session::Close() closes the connection and frees any resources.
    • Other methods for communicating with the session.

These should be interfaces to make code that uses them testable.

Optionally, we can have WandbProcessLauncher and SessionStarter, but I think we can get away with top-level Launch(settings) WandbProcess and Connect(address) Session functions.

The simplest usage in Go would be:

process := wandb.Launch(...)
defer process.Kill()

session := process.Connect()
defer session.Close()

session.Send(...)

Or to connect to a process running elsewhere:

session := wandb.Connect(...)
defer session.Close()

session.Send(...)

@dmitryduev dmitryduev marked this pull request as draft May 21, 2024 18:04
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.

None yet

3 participants