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(launch): put job into artifact slot, have run use it, dont produce a job in a launched run that is sourced from a job #4183

Merged
merged 6 commits into from Aug 26, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion wandb/sdk/launch/builder/build.py
Expand Up @@ -225,7 +225,14 @@ def get_env_vars_dict(launch_project: LaunchProject, api: Api) -> Dict[str, str]

# TODO: handle env vars > 32760 characters
env_vars["WANDB_CONFIG"] = json.dumps(launch_project.override_config)
env_vars["WANDB_ARTIFACTS"] = json.dumps(launch_project.override_artifacts)
artifacts = {}
# if we're spinning up a launch process from a job
# we should tell the run to use that artifact
if launch_project.job:
artifacts = {wandb.util.LAUNCH_JOB_ARTIFACT_SLOT_NAME: launch_project.job}
env_vars["WANDB_ARTIFACTS"] = json.dumps(
{**artifacts, **launch_project.override_artifacts}
)
# check if the user provided an override entrypoint, otherwise use the default

if launch_project.override_entrypoint is not None:
Expand Down
5 changes: 5 additions & 0 deletions wandb/sdk/wandb_init.py
Expand Up @@ -752,6 +752,11 @@ def init(self) -> Union[Run, RunDisabled, None]: # noqa: C901
# as the run is not upserted
for k, v in self.init_artifact_config.items():
run.config.update({k: v}, allow_val_change=True)
job_artifact = run._launch_artifact_mapping.get(
wandb.util.LAUNCH_JOB_ARTIFACT_SLOT_NAME
)
if job_artifact:
run.use_artifact(job_artifact)
KyleGoyette marked this conversation as resolved.
Show resolved Hide resolved

self.backend = backend
self._reporter.set_context(run=run)
Expand Down
6 changes: 6 additions & 0 deletions wandb/sdk/wandb_run.py
Expand Up @@ -2043,6 +2043,12 @@ def _on_ready(self) -> None:
self._freeze()

def _log_job(self) -> None:
# don't produce a job if the run is sourced from a job
KyleGoyette marked this conversation as resolved.
Show resolved Hide resolved
if (
self._launch_artifact_mapping.get(wandb.util.LAUNCH_JOB_ARTIFACT_SLOT_NAME)
is not None
):
return
artifact = None
input_types = TypeRegistry.type_of(self.config.as_dict()).to_json()
output_types = TypeRegistry.type_of(self.summary._as_dict()).to_json()
Expand Down
2 changes: 2 additions & 0 deletions wandb/util.py
Expand Up @@ -79,6 +79,8 @@
PLATFORM_DARWIN = "darwin"
PLATFORM_UNKNOWN = "unknown"

LAUNCH_JOB_ARTIFACT_SLOT_NAME = "_wandb_job"


def get_platform_name() -> str:
if sys.platform.startswith("win"):
Expand Down