How to use load_config method in yandex-tank

Best Python code snippet using yandex-tank

test_config_wrapper.py

Source:test_config_wrapper.py Github

copy

Full Screen

1from __future__ import absolute_import2import mock3from django.test import TestCase4from django_dynamic_fixture import get5import six6from readthedocs_build.config import BuildConfig, ProjectConfig, InvalidConfig7from readthedocs.builds.models import Version8from readthedocs.projects.models import Project9from readthedocs.doc_builder.config import ConfigWrapper, load_yaml_config10def create_load(config=None):11 """Mock out the function of the build load function12 This will create a ProjectConfig list of BuildConfig objects and validate13 them. The default load function iterates over files and builds up a list of14 objects. Instead of mocking all of this, just mock the end result.15 """16 if config is None:17 config = {}18 def inner(path=None, env_config=None):19 env_config_defaults = {20 'output_base': '',21 'name': '1',22 'type': 'sphinx',23 }24 if env_config is not None:25 env_config_defaults.update(env_config)26 yaml_config = ProjectConfig([27 BuildConfig(env_config_defaults,28 config,29 source_file='readthedocs.yml',30 source_position=0)31 ])32 yaml_config.validate()33 return yaml_config34 return inner35@mock.patch('readthedocs.doc_builder.config.load_config')36class LoadConfigTests(TestCase):37 def setUp(self):38 self.project = get(Project, main_language_project=None,39 install_project=False, requirements_file='urls.py')40 self.version = get(Version, project=self.project)41 def test_python_supported_versions_default_image_1_0(self, load_config):42 load_config.side_effect = create_load()43 self.project.container_image = 'readthedocs/build:1.0'44 self.project.save()45 config = load_yaml_config(self.version)46 self.assertEqual(load_config.call_count, 1)47 load_config.assert_has_calls([48 mock.call(path=mock.ANY, env_config={49 'python': {'supported_versions': [2, 2.7, 3, 3.4]},50 'type': 'sphinx',51 'output_base': '',52 'name': mock.ANY53 }),54 ])55 self.assertEqual(config.python_version, 2)56 def test_python_supported_versions_image_2_0(self, load_config):57 load_config.side_effect = create_load()58 self.project.container_image = 'readthedocs/build:2.0'59 self.project.save()60 config = load_yaml_config(self.version)61 self.assertEqual(load_config.call_count, 1)62 load_config.assert_has_calls([63 mock.call(path=mock.ANY, env_config={64 'python': {'supported_versions': [2, 2.7, 3, 3.5]},65 'type': 'sphinx',66 'output_base': '',67 'name': mock.ANY68 }),69 ])70 self.assertEqual(config.python_version, 2)71 def test_python_supported_versions_image_latest(self, load_config):72 load_config.side_effect = create_load()73 self.project.container_image = 'readthedocs/build:latest'74 self.project.save()75 config = load_yaml_config(self.version)76 self.assertEqual(load_config.call_count, 1)77 load_config.assert_has_calls([78 mock.call(path=mock.ANY, env_config={79 'python': {'supported_versions': [2, 2.7, 3, 3.3, 3.4, 3.5, 3.6]},80 'type': 'sphinx',81 'output_base': '',82 'name': mock.ANY83 }),84 ])85 self.assertEqual(config.python_version, 2)86 def test_python_default_version(self, load_config):87 load_config.side_effect = create_load()88 config = load_yaml_config(self.version)89 self.assertEqual(config.python_version, 2)90 self.assertEqual(config.python_interpreter, 'python2.7')91 def test_python_set_python_version_on_project(self, load_config):92 load_config.side_effect = create_load()93 self.project.container_image = 'readthedocs/build:2.0'94 self.project.python_interpreter = 'python3'95 self.project.save()96 config = load_yaml_config(self.version)97 self.assertEqual(config.python_version, 3)98 self.assertEqual(config.python_interpreter, 'python3.5')99 def test_python_set_python_version_in_config(self, load_config):100 load_config.side_effect = create_load({101 'python': {'version': 3.5}102 })103 self.project.container_image = 'readthedocs/build:2.0'104 self.project.save()105 config = load_yaml_config(self.version)106 self.assertEqual(config.python_version, 3.5)107 self.assertEqual(config.python_interpreter, 'python3.5')108 def test_python_invalid_version_in_config(self, load_config):109 load_config.side_effect = create_load({110 'python': {'version': 2.6}111 })112 self.project.container_image = 'readthedocs/build:2.0'113 self.project.save()114 with self.assertRaises(InvalidConfig):115 config = load_yaml_config(self.version)116 def test_install_project(self, load_config):117 load_config.side_effect = create_load()118 config = load_yaml_config(self.version)119 self.assertEqual(config.install_project, False)120 load_config.side_effect = create_load({121 'python': {'setup_py_install': True}122 })123 config = load_yaml_config(self.version)124 self.assertEqual(config.install_project, True)125 def test_extra_requirements(self, load_config):126 load_config.side_effect = create_load({127 'python': {128 'pip_install': True,129 'extra_requirements': ['tests', 'docs']130 }131 })132 config = load_yaml_config(self.version)133 self.assertEqual(config.extra_requirements, ['tests', 'docs'])134 load_config.side_effect = create_load({135 'python': {136 'extra_requirements': ['tests', 'docs']137 }138 })139 config = load_yaml_config(self.version)140 self.assertEqual(config.extra_requirements, [])141 load_config.side_effect = create_load()142 config = load_yaml_config(self.version)143 self.assertEqual(config.extra_requirements, [])144 load_config.side_effect = create_load({145 'python': {146 'setup_py_install': True,147 'extra_requirements': ['tests', 'docs']148 }149 })150 config = load_yaml_config(self.version)151 self.assertEqual(config.extra_requirements, [])152 def test_conda(self, load_config):153 to_find = 'urls.py'154 load_config.side_effect = create_load({155 'conda': {156 'file': to_find157 }158 })159 config = load_yaml_config(self.version)160 self.assertEqual(config.use_conda, True)161 self.assertTrue(config.conda_file[-len(to_find):] == to_find)162 load_config.side_effect = create_load()163 config = load_yaml_config(self.version)164 self.assertEqual(config.use_conda, False)165 self.assertEqual(config.conda_file, None)166 def test_requirements_file(self, load_config):167 if six.PY3:168 import pytest169 pytest.xfail("test_requirements_file is known to fail on 3.6")170 requirements_file = 'wsgi.py' if six.PY2 else 'readthedocs/wsgi.py'171 load_config.side_effect = create_load({172 'requirements_file': requirements_file173 })174 config = load_yaml_config(self.version)175 self.assertEqual(config.requirements_file, requirements_file)176 load_config.side_effect = create_load()177 config = load_yaml_config(self.version)...

Full Screen

Full Screen

main.py

Source:main.py Github

copy

Full Screen

1import pandas as pd2import numpy as np3from data_science_test_AT.utils_ import load_yaml4from data_science_test_AT.preprocess import (5 preprocess_pipes_from_files,6)7from data_science_test_AT.train import train_test_pipes_from_files, build_train_test8from data_science_test_AT.predict import call_model_from_files9from data_science_test_AT.kpis_performance import performance_kpis_from_files10import yaml11if __name__ == "__main__":12 load_config = load_yaml(yaml_path="competition_project\config_paths.yaml")13 if load_config["config_general"]["build_preprocess"] is not None:14 preprocess_pipes_from_files(15 request_df_path=load_config["config_preprocess"]["input_data_request"],16 individual_df_path=load_config["config_preprocess"][17 "input_data_individuals"18 ],19 select_var=load_config["config_preprocess"]["variables_selected"],20 common_var=load_config["config_preprocess"]["variable_for_join"],21 var_target=load_config["config_preprocess"]["variable_target"],22 output_directory=load_config["config_preprocess"]["output_path"],23 table_name=load_config["config_preprocess"]["tablename"],24 )25 if load_config["config_general"]["build_preprocess_test"] is not None:26 preprocess_pipes_from_files(27 request_df_path=load_config["config_preprocess_test"]["input_data_request"],28 individual_df_path=load_config["config_preprocess_test"][29 "input_data_individuals"30 ],31 select_var=load_config["config_preprocess_test"]["variables_selected"],32 common_var=load_config["config_preprocess"]["variable_for_join"],33 var_target=load_config["config_preprocess"]["variable_target"],34 output_directory=load_config["config_preprocess_test"]["output_path"],35 table_name=load_config["config_preprocess_test"]["tablename"],36 )37 if load_config["config_general"]["build_train"] is not None:38 train_test_pipes_from_files(39 input_df_path=load_config["config_train"]["input_data"],40 target_var=load_config["config_preprocess"]["variable_target"],41 common_var=load_config["config_preprocess"]["variable_for_join"],42 input_test_df_path=load_config["config_train"]["input_test_data"],43 output_directory=load_config["config_train"]["output_directory"],44 )45 if load_config["config_general"]["build_predict"] is not None:46 call_model_from_files(47 input_model_path=load_config["config_predict"]["input_model"],48 input_data_path=load_config["config_predict"]["input_data"],49 output_directory=load_config["config_predict"]["output_directory"],50 )51 if load_config["config_general"]["build_kpis"] is not None:52 performance_kpis_from_files(53 input_data_pred_path=load_config["config_kpis"]["input_data_pred"],54 input_data_assess_on=load_config["config_kpis"]["input_data_assess"],55 target_var=load_config["config_preprocess"]["variable_target"],56 output_directory=load_config["config_kpis"]["output_directory"],...

Full Screen

Full Screen

runner.py

Source:runner.py Github

copy

Full Screen

1from src.task_1.class_task1 import task_12from src.task_2.class_task2 import task_23from src.task_3.class_task3 import task_34from src.task_4.class_task4 import task_45from src.task_5.class_task5 import task_56from src.task_6.class_task6 import task_67from src.utils.files_operations import read_matrix_file, read_vector_file, read_json_file, read_pairs_file8def main(task):9 load_config = read_json_file("../../files/inputs/config.json")10 if(task == 1):11 matrix_a = read_matrix_file(load_config["Path_Matrix_A"])12 vector_b = read_vector_file(load_config["Path_Vector_B"])13 task_object = task_1(load_config["OrdemN"], load_config["ICOD"],14 load_config["IDET"], matrix_a, vector_b, load_config["TOLm"])15 task_object.run()16 elif(task == 2):17 matrix_a = read_matrix_file(load_config["Path_Matrix_A"])18 task_object = task_2(load_config["OrdemN"], load_config["ICOD"],19 load_config["IDET"], matrix_a, load_config["TOLm"])20 task_object.run()21 elif(task == 3):22 [values_x, values_y] = read_pairs_file(load_config["Path_Pairs"])23 task_object = task_3(24 load_config["ICOD"], load_config["Number_pairs_points"], load_config["xi"], values_x, values_y)25 task_object.run()26 elif(task == 4):27 task_object = task_4(28 load_config["ICOD"], load_config["theta1"], load_config["theta2"], load_config["TOLm"])29 task_object.run()30 elif(task == 5):31 task_object = task_5(32 load_config["ICOD"], load_config["c1"], load_config["c2"], load_config["c3"], load_config["c4"], load_config["a"], load_config["b"], load_config["delta_x"], load_config["TOLm"], load_config["count_points_integration"], load_config["point_a"], load_config["point_b"], load_config["method_defined_integral"], load_config["point_richard"], load_config["value_delta_x1"], load_config["value_delta_x2"])33 task_object.run()34 elif(task == 6):35 task_object = task_6(load_config["integration_step"], load_config["integration_time"], load_config["value_m"], load_config["value_c"], load_config["value_k"], load_config["list_a"], load_config["list_w"])36 task_object.run()37task = input("Escolha a task desejada ")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful