コード例 #1
0
 def test_simple_file_passes(self):
     plxfile = PolyaxonFile(os.path.abspath('tests/fixtures/simple_file.yml'))
     spec = plxfile.experiment_spec_at(0)
     assert plxfile.version == 1
     assert plxfile.project.name == 'project1'
     assert plxfile.project_path == '/tmp/plx_logs/project1'
     assert plxfile.matrix is None
     assert plxfile.settings is None
     assert plxfile.run_type == RunTypes.LOCAL
     assert spec.environment is None
     assert spec.experiment_path == '/tmp/plx_logs/project1/0'
     assert spec.is_runnable
     assert spec.cluster_def == ({TaskType.MASTER: 1}, False)
     assert_equal_dict(spec.get_cluster().to_dict(), {TaskType.MASTER: ['127.0.0.1:10000'],
                                                      TaskType.PS: [],
                                                      TaskType.WORKER: []})
     assert isinstance(spec.model, RegressorConfig)
     assert isinstance(spec.model.loss, MeanSquaredErrorConfig)
     assert isinstance(spec.model.optimizer, AdamConfig)
     assert isinstance(spec.model.graph, GraphConfig)
     assert len(spec.model.graph.layers) == 4
     assert spec.model.graph.input_layers == [['images', 0, 0]]
     last_layer = spec.model.graph.layers[-1].name
     assert spec.model.graph.output_layers == [[last_layer, 0, 0]]
     assert isinstance(spec.train.data_pipeline, TFRecordImagePipelineConfig)
     assert spec.eval is None
コード例 #2
0
    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
            )
コード例 #3
0
 def test_run_simple_file_passes(self):
     plxfile = PolyaxonFile(os.path.abspath('tests/fixtures/run_exec_simple_file.yml'))
     spec = plxfile.experiment_spec_at(0)
     assert plxfile.version == 1
     assert plxfile.project.name == 'video_prediction'
     assert plxfile.settings is None
     assert plxfile.run_type == RunTypes.LOCAL
     assert plxfile.project_path == "/tmp/plx_logs/video_prediction"
     assert spec.experiment_path == "/tmp/plx_logs/video_prediction/0"
     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)
     assert run_exec.cmd == "video_prediction_train --model=DNA --num_masks=1"
コード例 #4
0
    def test_matrix_file_passes(self):
        plxfile = PolyaxonFile(os.path.abspath('tests/fixtures/matrix_file.yml'))
        assert plxfile.version == 1
        assert plxfile.project.name == 'project1'
        assert plxfile.project_path == '/tmp/plx_logs/project1'
        assert isinstance(plxfile.matrix['lr'], MatrixConfig)
        assert isinstance(plxfile.matrix['loss'], MatrixConfig)
        assert plxfile.matrix['lr'].to_dict() == {
            'logspace': {'start': 0.01, 'stop': 0.1, 'num': 5}}
        assert plxfile.matrix['loss'].to_dict() == {'values': ['MeanSquaredError',
                                                               'AbsoluteDifference']}
        assert plxfile.matrix_space == 10
        declarations = []
        for lr in plxfile.matrix['lr'].to_numpy():
            for loss in plxfile.matrix['loss'].to_numpy():
                declarations.append({'loss': loss, 'lr': lr})
        assert sorted(
            plxfile.matrix_declarations, key=lambda x: (x['lr'], x['loss'])) == sorted(
            declarations, key=lambda x: (x['lr'], x['loss']))
        assert isinstance(plxfile.settings, SettingsConfig)
        assert plxfile.settings.concurrent_experiments == 2
        assert plxfile.run_type == RunTypes.LOCAL

        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_equal_dict(spec.get_cluster().to_dict(),
                              {TaskType.MASTER: ['127.0.0.1:10000'],
                               TaskType.PS: [],
                               TaskType.WORKER: []})
            model = spec.model
            assert isinstance(model, RegressorConfig)
            assert isinstance(model.loss, (MeanSquaredErrorConfig, AbsoluteDifferenceConfig))
            assert isinstance(model.optimizer, AdamConfig)
            assert isinstance(model.graph, GraphConfig)
            assert len(model.graph.layers) == 4
            assert model.graph.input_layers == [['images', 0, 0]]
            last_layer = model.graph.layers[-1].name
            assert model.graph.output_layers == [[last_layer, 0, 0]]
            assert isinstance(spec.train.data_pipeline, TFRecordImagePipelineConfig)
コード例 #5
0
 def test_simple_generator_file_passes(self):
     plxfile = PolyaxonFile(os.path.abspath('tests/fixtures/simple_generator_file.yml'))
     spec = plxfile.experiment_spec_at(0)
     assert plxfile.matrix is None
     assert plxfile.version == 1
     assert plxfile.project.name == 'project1'
     assert plxfile.project_path == '/tmp/plx_logs/project1'
     assert plxfile.settings is None
     assert plxfile.run_type == RunTypes.LOCAL
     assert spec.experiment_path == '/tmp/plx_logs/project1/0'
     assert spec.environment is None
     assert spec.is_runnable
     assert spec.cluster_def == ({TaskType.MASTER: 1}, False)
     assert_equal_dict(spec.get_cluster().to_dict(), {TaskType.MASTER: ['127.0.0.1:10000'],
                                                      TaskType.PS: [],
                                                      TaskType.WORKER: []})
     assert isinstance(spec.model, GeneratorConfig)
     assert isinstance(spec.model.loss, MeanSquaredErrorConfig)
     assert isinstance(spec.model.optimizer, AdamConfig)
     assert isinstance(spec.model.encoder, GraphConfig)
     assert isinstance(spec.model.decoder, GraphConfig)
     assert isinstance(spec.model.bridge, NoOpBridgeConfig)
     assert isinstance(spec.train.data_pipeline, TFRecordImagePipelineConfig)
     assert spec.eval is None
コード例 #6
0
    def test_advanced_file_passes(self):
        plxfile = PolyaxonFile(os.path.abspath('tests/fixtures/advanced_file.yml'))
        assert plxfile.version == 1
        assert plxfile.project.name == 'project1'
        assert plxfile.project_path == '/mypath/project1'
        assert plxfile.matrix is None
        assert plxfile.run_type == RunTypes.MINIKUBE
        assert isinstance(plxfile.settings, SettingsConfig)
        assert isinstance(plxfile.settings.logging, LoggingConfig)
        spec = plxfile.experiment_spec_at(0)
        assert spec.is_runnable
        assert isinstance(spec.environment, EnvironmentConfig)
        assert spec.environment.n_workers == 5
        assert spec.environment.n_ps == 10
        assert spec.environment.delay_workers_by_global_step is True
        assert isinstance(spec.environment.run_config, RunConfig)
        assert spec.environment.run_config.tf_random_seed == 100
        assert spec.environment.run_config.save_summary_steps == 100
        assert spec.environment.run_config.save_checkpoints_secs == 60
        assert isinstance(spec.environment.run_config.session, SessionConfig)
        assert spec.environment.run_config.session.allow_soft_placement is True
        assert spec.environment.run_config.session.intra_op_parallelism_threads == 2
        assert spec.environment.run_config.session.inter_op_parallelism_threads == 2

        # check properties for returning worker configs and resources
        assert spec.environment.worker_configs is None
        assert spec.environment.ps_configs is None
        assert spec.environment.resources is None
        assert spec.environment.worker_resources is None
        assert spec.environment.ps_resources is None

        assert spec.worker_configs == {}
        assert spec.ps_configs == {}
        assert spec.worker_resources == {}
        assert spec.ps_resources == {}

        assert spec.cluster_def == ({TaskType.MASTER: 1,
                                        TaskType.WORKER: 5,
                                        TaskType.PS: 10}, True)

        def task_name(task_type, task_idx):
            return constants.TASK_NAME.format(project=plxfile.project.name,
                                              experiment=0,
                                              task_type=task_type,
                                              task_idx=task_idx)

        assert_equal_dict(spec.get_cluster().to_dict(),
                          {TaskType.MASTER: ['{}:2222'.format(task_name(TaskType.MASTER, 0))],
                           TaskType.WORKER: [
                               '{}:2222'.format(task_name(TaskType.WORKER, 0)),
                               '{}:2222'.format(task_name(TaskType.WORKER, 1)),
                               '{}:2222'.format(task_name(TaskType.WORKER, 2)),
                               '{}:2222'.format(task_name(TaskType.WORKER, 3)),
                               '{}:2222'.format(task_name(TaskType.WORKER, 4)),
                           ],
                           TaskType.PS: [
                               '{}:2222'.format(task_name(TaskType.PS, 0)),
                               '{}:2222'.format(task_name(TaskType.PS, 1)),
                               '{}:2222'.format(task_name(TaskType.PS, 2)),
                               '{}:2222'.format(task_name(TaskType.PS, 3)),
                               '{}:2222'.format(task_name(TaskType.PS, 4)),
                               '{}:2222'.format(task_name(TaskType.PS, 5)),
                               '{}:2222'.format(task_name(TaskType.PS, 6)),
                               '{}:2222'.format(task_name(TaskType.PS, 7)),
                               '{}:2222'.format(task_name(TaskType.PS, 8)),
                               '{}:2222'.format(task_name(TaskType.PS, 9)),
                           ]})
        assert isinstance(spec.model, ClassifierConfig)
        assert isinstance(spec.model.loss, MeanSquaredErrorConfig)
        assert isinstance(spec.model.optimizer, AdamConfig)
        assert spec.model.optimizer.learning_rate == 0.21
        assert isinstance(spec.model.graph, GraphConfig)
        assert len(spec.model.graph.layers) == 7
        assert spec.model.graph.input_layers == [['images', 0, 0]]
        assert len(spec.model.graph.output_layers) == 3
        assert ['super_dense', 0, 0] in spec.model.graph.output_layers
        assert isinstance(spec.train.data_pipeline, TFRecordImagePipelineConfig)
        assert len(spec.train.data_pipeline.feature_processors.feature_processors) == 1
        assert isinstance(spec.eval.data_pipeline, TFRecordImagePipelineConfig)
        assert spec.eval.data_pipeline.feature_processors is None