def __init__(self, project=None, client=None, track_logs=True, track_code=True, track_env=True, outputs_store=None): if settings.NO_OP: return if not settings.IN_CLUSTER and project is None: raise PolyaxonClientException('Please provide a valid project.') self.client = client or PolyaxonClient() if settings.IN_CLUSTER: self.user = None else: self.user = (self.client.auth.get_user().username if self.client.api_config.schema_response else self.client.auth.get_user().get('username')) username, project_name = get_project_info(current_user=self.user, project=project) self.track_logs = track_logs self.track_code = track_code self.track_env = track_env self.project = project self.username = username self.project_name = project_name self.outputs_store = outputs_store # Setup the outputs store if outputs_store is None and settings.IN_CLUSTER: self.set_outputs_store(outputs_path=get_outputs_path(), set_env_vars=True)
def __init__(self, project=None, client=None, track_logs=True, track_code=True, track_env=True, outputs_store=None): if not settings.IS_MANAGED and project is None: raise PolyaxonClientException('Please provide a valid project.') elif self.is_notebook_job: job_info = self.get_notebook_job_info() project = job_info['project_name'] self.last_status = None self.client = client self.user = None if not (self.client or settings.IS_OFFLINE): self.client = PolyaxonClient() if self.client and not settings.IS_MANAGED: self.user = (self.client.auth.get_user().username if self.client.api_config.schema_response else self.client.auth.get_user().get('username')) username, project_name = get_project_info(current_user=self.user, project=project) self.track_logs = track_logs self.track_code = track_code self.track_env = track_env self.project = project self.username = username self.project_name = project_name self.outputs_store = outputs_store self._entity_data = None self._health_is_running = False # Setup the outputs store if outputs_store is None and settings.IS_MANAGED and self.REQUIRES_OUTPUTS: self.set_outputs_store(outputs_path=get_outputs_path(), set_env_vars=True)
def get_tf_config(cls, envvar='TF_CONFIG'): """ Returns the TF_CONFIG defining the cluster and the current task. if `envvar` is not null, it will set and env variable with `envvar`. """ if settings.NO_OP: return None ensure_is_managed() cluster_def = cls.get_cluster_def() task_info = cls.get_task_info() tf_config = { 'cluster': cluster_def, 'task': task_info, 'model_dir': get_outputs_path(), 'environment': 'cloud' } if envvar: os.environ[envvar] = json.dumps(tf_config) return tf_config
def get_outputs_path(self): # TODO: Add handling for experiment running out of Polyaxon return get_outputs_path()
def get_outputs_path(self): return get_outputs_path()
def test_get_outputs_raises_out_cluster(self): settings.IN_CLUSTER = False with self.assertRaises(PolyaxonClientException): paths.get_outputs_path()