Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
add some non-interactive options for wandb init
Browse files Browse the repository at this point in the history
  • Loading branch information
raubitsj committed Aug 9, 2020
1 parent 86536da commit 501a72e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docker-pycreds>=0.4.0
configparser>=3.8.1
protobuf>=3.12.0
PyYAML
typing; python_version < '3.5'
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
with open('requirements.txt') as requirements_file:
requirements = requirements_file.read().splitlines()

if sys.version_info < (3, 5):
requirements.append('typing')

test_requirements = [
'mock>=2.0.0',
'tox-pyenv>=1.0.3'
Expand Down
22 changes: 21 additions & 1 deletion wandb/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,32 @@ def superagent(project=None, entity=None, agent_spec=None):


@cli.command(context_settings=CONTEXT, help="Configure a directory with Weights & Biases")
@click.option("--project", "-p", help="The project to use.")
@click.option("--entity", "-e", help="The entity to scope the project to.")
# TODO(jhr): Enable these with settings rework
# @click.option("--setting", "-s", help="enable an arbitrary setting.", multiple=True)
# @click.option('--show', is_flag=True, help="Show settings")
@click.option('--reset', is_flag=True, help="Reset settings")
@click.pass_context
@display_error
def init(ctx):
def init(ctx, project, entity, reset):
from wandb.old.core import _set_stage_dir, __stage_dir__, wandb_dir
if __stage_dir__ is None:
_set_stage_dir('wandb')

# non interactive init
if reset or project or entity:
api = InternalApi()
if reset:
api.clear_setting("entity", persist=True)
api.clear_setting("project", persist=True)
# TODO(jhr): clear more settings?
if entity:
api.set_setting('entity', entity, persist=True)
if project:
api.set_setting('project', project, persist=True)
return

if os.path.isdir(wandb_dir()) and os.path.exists(os.path.join(wandb_dir(), "settings")):
click.confirm(click.style(
"This directory has been configured previously, should we re-configure it?", bold=True), abort=True)
Expand Down

0 comments on commit 501a72e

Please sign in to comment.