def _test_namespace(self): from metaflow.client import Flow, get_namespace, namespace, default_namespace from metaflow.exception import MetaflowNamespaceMismatch import os # test 1) METAFLOW_USER should be the default assert_equals("user:%s" % os.environ.get("METAFLOW_USER"), get_namespace()) # test 2) Run should be in the listing assert_equals(True, self.run_id in [run.id for run in Flow(self.flow.name)]) # test 3) changing namespace should change namespace namespace("user:nobody") assert_equals(get_namespace(), "user:nobody") # test 4) fetching results in the incorrect namespace should fail assert_exception(lambda: Flow(self.flow.name)[self.run_id], MetaflowNamespaceMismatch) # test 5) global namespace should work namespace(None) assert_equals(get_namespace(), None) Flow(self.flow.name)[self.run_id] default_namespace()
def status(): from metaflow.client import get_metadata res = get_metadata() if res: res = res.split("@") else: raise click.ClickException( "Unknown status: cannot find a Metadata provider") if res[0] == "service": echo("Using Metadata provider at: ", nl=False) echo('"%s"\n' % res[1], fg="cyan") echo("To list available flows, type:\n") echo("1. python") echo("2. from metaflow import Metaflow") echo("3. list(Metaflow())") return from metaflow.client import namespace, metadata, Metaflow # Get the local data store path path = LocalStorage.get_datastore_root_from_config(echo, create_on_absent=False) # Throw an exception if path is None: raise click.ClickException( "Could not find " + click.style('"%s"' % DATASTORE_LOCAL_DIR, fg="red") + " in the current working tree.") stripped_path = os.path.dirname(path) namespace(None) metadata("local@%s" % stripped_path) echo("Working tree found at: ", nl=False) echo('"%s"\n' % stripped_path, fg="cyan") echo("Available flows:", fg="cyan", bold=True) for flow in Metaflow(): echo("* %s" % flow, fg="cyan")
def status(): from metaflow.client import get_metadata res = get_metadata() if res: res = res.split('@') else: raise click.ClickException( 'Unknown status: cannot find a Metadata provider') if res[0] == 'service': echo('Using Metadata provider at: ', nl=False) echo('"%s"\n' % res[1], fg='cyan') echo('To list available flows, type:\n') echo('1. python') echo('2. from metaflow import Metaflow') echo('3. list(Metaflow())') return from metaflow.client import namespace, metadata, Metaflow # Get the local data store path path = LocalDataStore.get_datastore_root_from_config( echo, create_on_absent=False) # Throw an exception if path is None: raise click.ClickException("Could not find " +\ click.style('"%s"' % DATASTORE_LOCAL_DIR, fg='red') +\ " in the current working tree.") stripped_path = os.path.dirname(path) namespace(None) metadata('local@%s' % stripped_path) echo('Working tree found at: ', nl=False) echo('"%s"\n' % stripped_path, fg='cyan') echo('Available flows:', fg='cyan', bold=True) for flow in Metaflow(): echo('* %s' % flow, fg='cyan')