Skip to content

Commit

Permalink
feat(launch): put job into artifact slot, have run use it, dont produ…
Browse files Browse the repository at this point in the history
…ce a job in a launched run that is sourced from a job (#4183)

* put job into artifact slot, have run use it

* fix up

* remove unnecessary change
  • Loading branch information
KyleGoyette committed Aug 26, 2022
1 parent 6f330d4 commit f838ebe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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)

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
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

0 comments on commit f838ebe

Please sign in to comment.