def test_run_matrix_file_passes(self):
        plxfile = PolyaxonFile(os.path.abspath('tests/fixtures/run_exec_matrix_file.yml'))
        assert plxfile.version == 1
        assert plxfile.project.name == 'video_prediction'
        assert plxfile.project_path == get_vol_path(constants.LOGS_VOLUME,
                                                    RunTypes.MINIKUBE) + 'video_prediction'
        assert isinstance(plxfile.matrix['model'], MatrixConfig)
        assert plxfile.matrix['model'].to_dict() == {'values': ['CDNA', 'DNA', 'STP']}
        assert plxfile.matrix_space == 3
        declarations = []
        for loss in plxfile.matrix['model'].to_numpy():
            declarations.append({'model': loss})
        assert sorted(
            plxfile.matrix_declarations, key=lambda x: (x['model'])) == sorted(
            declarations, key=lambda x: (x['model']))
        assert isinstance(plxfile.settings, SettingsConfig)
        assert plxfile.run_type == RunTypes.MINIKUBE
        assert len(plxfile.experiment_specs) == plxfile.matrix_space

        for xp in range(plxfile.matrix_space):
            spec = plxfile.experiment_spec_at(xp)
            assert spec.is_runnable
            assert spec.environment is None
            assert spec.cluster_def == ({TaskType.MASTER: 1}, False)
            assert spec.model is None
            run_exec = spec.run_exec
            assert isinstance(run_exec, RunExecConfig)
            declarations = plxfile.get_declarations_at(xp)
            declarations['num_masks'] = 1 if declarations['model'] == 'DNA' else 10
            assert run_exec.cmd == 'video_prediction_train --model="{model}" --num_masks={num_masks}'.format(
                **declarations
            )
Beispiel #2
0
def get_persistent_volume_spec(namespace,
                               volume,
                               run_type,
                               access_modes='ReadWriteOnce',
                               persistent_volume_reclaim_policy='Recycle'):
    capacity = {'storage': STORAGE_BY_VOLUME[volume]}
    access_modes = to_list(access_modes)
    vol_path = get_vol_path(volume, run_type)
    if run_type == RunTypes.MINIKUBE:
        params = get_host_path_pvol(vol_path)
    elif run_type == RunTypes.KUBERNETES:
        params = get_nfs_pvol(vol_path)
    else:
        raise PolyaxonConfigurationError(
            'Run type `{}` is not allowed.'.format(run_type))

    volc_name = constants.VOLUME_CLAIM_NAME.format(vol_name=volume)
    claim_ref = client.V1ObjectReference(
        api_version=k8s_constants.K8S_API_VERSION_V1,
        kind=k8s_constants.K8S_PERSISTENT_VOLUME_CLAIM_KIND,
        name=volc_name,
        namespace=namespace)
    return client.V1PersistentVolumeSpec(
        capacity=capacity,
        access_modes=access_modes,
        persistent_volume_reclaim_policy=persistent_volume_reclaim_policy,
        claim_ref=claim_ref,
        **params)
        def get_path():
            project_path = None
            if self.settings:
                project_path = self.settings.logging.path

            if project_path:
                return project_path

            if self.run_type == RunTypes.LOCAL:
                return '/tmp/plx_logs/' + self.project.name

            return get_vol_path(constants.LOGS_VOLUME,
                                self.run_type) + self.project.name