GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-aiplatform/samples/model-builder/conftest.py at main · smbale/python-aiplatform Expand file tree/ Copy pathconftest.pyMore file actions 1442 lines (1029 loc) · 40.9 KB / Copy pathconftest.pyFile metadata and controls1442 lines (1029 loc) · 40.9 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 # Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from unittest.mock import MagicMock from unittest.mock import patch from google.cloud import aiplatform import vertexai from vertexai.resources import preview as preview_resources import pytest @pytest.fixture def mock_sdk_init(): with patch.object(aiplatform, "init") as mock: yield mock @pytest.fixture def mock_vertexai_init(): with patch.object(vertexai, "init") as mock: yield mock """ ---------------------------------------------------------------------------- Dataset Fixtures ---------------------------------------------------------------------------- """ """Dataset objects returned by SomeDataset(), create(), import_data(), etc. """ @pytest.fixture def mock_image_dataset(): mock = MagicMock(aiplatform.datasets.ImageDataset) yield mock @pytest.fixture def mock_tabular_dataset(): mock = MagicMock(aiplatform.datasets.TabularDataset) yield mock @pytest.fixture def mock_time_series_dataset(): mock = MagicMock(aiplatform.datasets.TimeSeriesDataset) yield mock @pytest.fixture def mock_text_dataset(): mock = MagicMock(aiplatform.datasets.TextDataset) yield mock @pytest.fixture def mock_video_dataset(): mock = MagicMock(aiplatform.datasets.VideoDataset) yield mock """Mocks for getting an existing Dataset, i.e. ds = aiplatform.ImageDataset(...) """ @pytest.fixture def mock_get_image_dataset(mock_image_dataset): with patch.object(aiplatform, "ImageDataset") as mock_get_image_dataset: mock_get_image_dataset.return_value = mock_image_dataset yield mock_get_image_dataset @pytest.fixture def mock_get_tabular_dataset(mock_tabular_dataset): with patch.object(aiplatform, "TabularDataset") as mock_get_tabular_dataset: mock_get_tabular_dataset.return_value = mock_tabular_dataset yield mock_get_tabular_dataset @pytest.fixture def mock_get_time_series_dataset(mock_time_series_dataset): with patch.object(aiplatform, "TimeSeriesDataset") as mock_get_time_series_dataset: mock_get_time_series_dataset.return_value = mock_time_series_dataset yield mock_get_time_series_dataset @pytest.fixture def mock_get_text_dataset(mock_text_dataset): with patch.object(aiplatform, "TextDataset") as mock_get_text_dataset: mock_get_text_dataset.return_value = mock_text_dataset yield mock_get_text_dataset @pytest.fixture def mock_get_video_dataset(mock_video_dataset): with patch.object(aiplatform, "VideoDataset") as mock_get_video_dataset: mock_get_video_dataset.return_value = mock_video_dataset yield mock_get_video_dataset """Mocks for creating a new Dataset, i.e. aiplatform.ImageDataset.create(...) """ @pytest.fixture def mock_create_image_dataset(mock_image_dataset): with patch.object(aiplatform.ImageDataset, "create") as mock_create_image_dataset: mock_create_image_dataset.return_value = mock_image_dataset yield mock_create_image_dataset @pytest.fixture def mock_create_tabular_dataset(mock_tabular_dataset): with patch.object( aiplatform.TabularDataset, "create" ) as mock_create_tabular_dataset: mock_create_tabular_dataset.return_value = mock_tabular_dataset yield mock_create_tabular_dataset @pytest.fixture def mock_create_time_series_dataset(mock_time_series_dataset): with patch.object( aiplatform.TimeSeriesDataset, "create" ) as mock_create_time_series_dataset: mock_create_time_series_dataset.return_value = mock_time_series_dataset yield mock_create_time_series_dataset @pytest.fixture def mock_create_text_dataset(mock_text_dataset): with patch.object(aiplatform.TextDataset, "create") as mock_create_text_dataset: mock_create_text_dataset.return_value = mock_text_dataset yield mock_create_text_dataset @pytest.fixture def mock_create_video_dataset(mock_video_dataset): with patch.object(aiplatform.VideoDataset, "create") as mock_create_video_dataset: mock_create_video_dataset.return_value = mock_video_dataset yield mock_create_video_dataset """Mocks for SomeDataset.import_data() """ @pytest.fixture def mock_import_image_dataset(mock_image_dataset): with patch.object(mock_image_dataset, "import_data") as mock: yield mock @pytest.fixture def mock_import_tabular_dataset(mock_tabular_dataset): with patch.object(mock_tabular_dataset, "import_data") as mock: yield mock @pytest.fixture def mock_import_text_dataset(mock_text_dataset): with patch.object(mock_text_dataset, "import_data") as mock: yield mock @pytest.fixture def mock_import_video_data(mock_video_dataset): with patch.object(mock_video_dataset, "import_data") as mock: yield mock # ---------------------------------------------------------------------------- # TrainingJob Fixtures # ---------------------------------------------------------------------------- @pytest.fixture def mock_custom_training_job(): mock = MagicMock(aiplatform.training_jobs.CustomTrainingJob) yield mock @pytest.fixture def mock_custom_container_training_job(): mock = MagicMock(aiplatform.training_jobs.CustomContainerTrainingJob) yield mock @pytest.fixture def mock_custom_package_training_job(): mock = MagicMock(aiplatform.training_jobs.CustomPythonPackageTrainingJob) yield mock @pytest.fixture def mock_image_training_job(): mock = MagicMock(aiplatform.training_jobs.AutoMLImageTrainingJob) yield mock @pytest.fixture def mock_tabular_training_job(): mock = MagicMock(aiplatform.training_jobs.AutoMLTabularTrainingJob) yield mock @pytest.fixture def mock_forecasting_training_job(): mock = MagicMock(aiplatform.training_jobs.AutoMLForecastingTrainingJob) yield mock @pytest.fixture def mock_text_training_job(): mock = MagicMock(aiplatform.training_jobs.AutoMLTextTrainingJob) yield mock @pytest.fixture def mock_video_training_job(): mock = MagicMock(aiplatform.training_jobs.AutoMLVideoTrainingJob) yield mock @pytest.fixture def mock_get_automl_tabular_training_job(mock_tabular_training_job): with patch.object(aiplatform, "AutoMLTabularTrainingJob") as mock: mock.return_value = mock_tabular_training_job yield mock @pytest.fixture def mock_run_automl_tabular_training_job(mock_tabular_training_job): with patch.object(mock_tabular_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_automl_forecasting_training_job(mock_forecasting_training_job): with patch.object(aiplatform, "AutoMLForecastingTrainingJob") as mock: mock.return_value = mock_forecasting_training_job yield mock @pytest.fixture def mock_run_automl_forecasting_training_job(mock_forecasting_training_job): with patch.object(mock_forecasting_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_automl_forecasting_seq2seq_training_job(mock_forecasting_training_job): with patch.object( aiplatform, "SequenceToSequencePlusForecastingTrainingJob" ) as mock: mock.return_value = mock_forecasting_training_job yield mock @pytest.fixture def mock_run_automl_forecasting_seq2seq_training_job(mock_forecasting_training_job): with patch.object(mock_forecasting_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_automl_forecasting_tft_training_job(mock_forecasting_training_job): with patch.object( aiplatform, "TemporalFusionTransformerForecastingTrainingJob" ) as mock: mock.return_value = mock_forecasting_training_job yield mock @pytest.fixture def mock_run_automl_forecasting_tft_training_job(mock_forecasting_training_job): with patch.object(mock_forecasting_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_automl_forecasting_tide_training_job(mock_forecasting_training_job): with patch.object( aiplatform, "TimeSeriesDenseEncoderForecastingTrainingJob" ) as mock: mock.return_value = mock_forecasting_training_job yield mock @pytest.fixture def mock_run_automl_forecasting_tide_training_job(mock_forecasting_training_job): with patch.object(mock_forecasting_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_automl_image_training_job(mock_image_training_job): with patch.object(aiplatform, "AutoMLImageTrainingJob") as mock: mock.return_value = mock_image_training_job yield mock @pytest.fixture def mock_run_automl_image_training_job(mock_image_training_job): with patch.object(mock_image_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_automl_text_training_job(mock_text_training_job): with patch.object(aiplatform, "AutoMLTextTrainingJob") as mock: mock.return_value = mock_text_training_job yield mock @pytest.fixture def mock_run_automl_text_training_job(mock_text_training_job): with patch.object(mock_text_training_job, "run") as mock: yield mock @pytest.fixture def mock_get_custom_training_job(mock_custom_training_job): with patch.object(aiplatform, "CustomTrainingJob") as mock: mock.return_value = mock_custom_training_job yield mock @pytest.fixture def mock_get_custom_container_training_job(mock_custom_container_training_job): with patch.object(aiplatform, "CustomContainerTrainingJob") as mock: mock.return_value = mock_custom_container_training_job yield mock @pytest.fixture def mock_get_custom_package_training_job(mock_custom_package_training_job): with patch.object(aiplatform, "CustomPythonPackageTrainingJob") as mock: mock.return_value = mock_custom_package_training_job yield mock @pytest.fixture def mock_run_custom_training_job(mock_custom_training_job): with patch.object(mock_custom_training_job, "run") as mock: yield mock @pytest.fixture def mock_run_custom_container_training_job(mock_custom_container_training_job): with patch.object(mock_custom_container_training_job, "run") as mock: yield mock @pytest.fixture def mock_run_custom_package_training_job(mock_custom_package_training_job): with patch.object(mock_custom_package_training_job, "run") as mock: yield mock @pytest.fixture def mock_custom_job(): mock = MagicMock(aiplatform.CustomJob) yield mock @pytest.fixture def mock_get_custom_job(mock_custom_job): with patch.object(aiplatform, "CustomJob") as mock: mock.return_value = mock_custom_job yield mock @pytest.fixture def mock_get_custom_job_from_local_script(mock_custom_job): with patch.object(aiplatform.CustomJob, "from_local_script") as mock: mock.return_value = mock_custom_job yield mock @pytest.fixture def mock_run_custom_job(mock_custom_job): with patch.object(mock_custom_job, "run") as mock: yield mock """ ---------------------------------------------------------------------------- Model Fixtures ---------------------------------------------------------------------------- """ @pytest.fixture def mock_model(): mock = MagicMock(aiplatform.models.Model) yield mock @pytest.fixture def mock_init_model(mock_model): with patch.object(aiplatform, "Model") as mock: mock.return_value = mock_model yield mock @pytest.fixture def mock_batch_predict_model(mock_model): with patch.object(mock_model, "batch_predict") as mock: yield mock @pytest.fixture def mock_upload_model(mock_model): with patch.object(aiplatform.Model, "upload") as mock: mock.return_value = mock_model yield mock @pytest.fixture def mock_deploy_model(mock_model, mock_endpoint): with patch.object(mock_model, "deploy") as mock: mock.return_value = mock_endpoint yield mock """ ---------------------------------------------------------------------------- Job Fixtures ---------------------------------------------------------------------------- """ @pytest.fixture def mock_create_batch_prediction_job(): with patch.object(aiplatform.jobs.BatchPredictionJob, "create") as mock: yield mock """ ---------------------------------------------------------------------------- Tensorboard Fixtures ---------------------------------------------------------------------------- """ @pytest.fixture def mock_tensorboard(): mock = MagicMock(aiplatform.Tensorboard) yield mock @pytest.fixture def mock_TensorBoard_uploaderTracker(): mock = MagicMock(aiplatform.uploader_tracker) yield mock @pytest.fixture def mock_create_tensorboard(mock_tensorboard): with patch.object(aiplatform.Tensorboard, "create") as mock: mock.return_value = mock_tensorboard yield mock @pytest.fixture def mock_get_tensorboard(mock_tensorboard): with patch.object(aiplatform, "Tensorboard") as mock_get_tensorboard: mock_get_tensorboard.return_value = mock_tensorboard yield mock_get_tensorboard @pytest.fixture def mock_tensorboard_delete(mock_tensorboard): with patch.object(mock_tensorboard, "delete") as mock_tensorboard_delete: yield mock_tensorboard_delete @pytest.fixture def mock_tensorboard_uploader_onetime(): with patch.object(aiplatform, "upload_tb_log") as mock_tensorboard_uploader_onetime: mock_tensorboard_uploader_onetime.return_value = None yield mock_tensorboard_uploader_onetime @pytest.fixture def mock_tensorboard_uploader_start(): with patch.object( aiplatform, "start_upload_tb_log" ) as mock_tensorboard_uploader_start: mock_tensorboard_uploader_start.return_value = None yield mock_tensorboard_uploader_start @pytest.fixture def mock_tensorboard_uploader_end(): with patch.object(aiplatform, "end_upload_tb_log") as mock_tensorboard_uploader_end: mock_tensorboard_uploader_end.return_value = None yield mock_tensorboard_uploader_end """ ---------------------------------------------------------------------------- Endpoint Fixtures ---------------------------------------------------------------------------- """ @pytest.fixture def mock_endpoint(): mock = MagicMock(aiplatform.models.Endpoint) yield mock @pytest.fixture def mock_create_endpoint(): with patch.object(aiplatform.models.Endpoint, "create") as mock: yield mock @pytest.fixture def mock_get_endpoint(mock_endpoint): with patch.object(aiplatform, "Endpoint") as mock_get_endpoint: mock_get_endpoint.return_value = mock_endpoint yield mock_get_endpoint @pytest.fixture def mock_endpoint_predict(mock_endpoint): with patch.object(mock_endpoint, "predict") as mock: mock.return_value = [] yield mock @pytest.fixture def mock_endpoint_explain(mock_endpoint): with patch.object(mock_endpoint, "explain") as mock_endpoint_explain: mock_get_endpoint.return_value = mock_endpoint yield mock_endpoint_explain # ---------------------------------------------------------------------------- # Hyperparameter Tuning Job Fixtures # ---------------------------------------------------------------------------- @pytest.fixture def mock_hyperparameter_tuning_job(): mock = MagicMock(aiplatform.HyperparameterTuningJob) yield mock @pytest.fixture def mock_get_hyperparameter_tuning_job(mock_hyperparameter_tuning_job): with patch.object(aiplatform, "HyperparameterTuningJob") as mock: mock.return_value = mock_hyperparameter_tuning_job yield mock @pytest.fixture def mock_run_hyperparameter_tuning_job(mock_hyperparameter_tuning_job): with patch.object(mock_hyperparameter_tuning_job, "run") as mock: yield mock @pytest.fixture def mock_hyperparameter_tuning_job_get(mock_hyperparameter_tuning_job): with patch.object( aiplatform.HyperparameterTuningJob, "get" ) as mock_hyperparameter_tuning_job_get: mock_hyperparameter_tuning_job_get.return_value = mock_hyperparameter_tuning_job yield mock_hyperparameter_tuning_job_get @pytest.fixture def mock_hyperparameter_tuning_job_cancel(mock_hyperparameter_tuning_job): with patch.object(mock_hyperparameter_tuning_job, "cancel") as mock: yield mock @pytest.fixture def mock_hyperparameter_tuning_job_delete(mock_hyperparameter_tuning_job): with patch.object(mock_hyperparameter_tuning_job, "delete") as mock: yield mock """ ---------------------------------------------------------------------------- Feature Store Fixtures ---------------------------------------------------------------------------- """ @pytest.fixture def mock_featurestore(): mock = MagicMock(aiplatform.featurestore.Featurestore) yield mock @pytest.fixture def mock_entity_type(): mock = MagicMock(aiplatform.featurestore.EntityType) yield mock @pytest.fixture def mock_feature(): mock = MagicMock(aiplatform.featurestore.Feature) yield mock @pytest.fixture def mock_get_featurestore(mock_featurestore): with patch.object(aiplatform.featurestore, "Featurestore") as mock_get_featurestore: mock_get_featurestore.return_value = mock_featurestore yield mock_get_featurestore @pytest.fixture def mock_get_entity_type(mock_entity_type): with patch.object(aiplatform.featurestore, "EntityType") as mock_get_entity_type: mock_get_entity_type.return_value = mock_entity_type yield mock_get_entity_type @pytest.fixture def mock_create_featurestore(mock_featurestore): with patch.object( aiplatform.featurestore.Featurestore, "create" ) as mock_create_featurestore: mock_create_featurestore.return_value = mock_featurestore yield mock_create_featurestore @pytest.fixture def mock_create_entity_type(mock_entity_type): with patch.object( aiplatform.featurestore.EntityType, "create" ) as mock_create_entity_type: mock_create_entity_type.return_value = mock_entity_type yield mock_create_entity_type @pytest.fixture def mock_create_feature(mock_feature): with patch.object(aiplatform.featurestore.Feature, "create") as mock_create_feature: mock_create_feature.return_value = mock_feature yield mock_create_feature @pytest.fixture def mock_delete_featurestore(mock_featurestore): with patch.object(mock_featurestore, "delete") as mock_delete_featurestore: yield mock_delete_featurestore @pytest.fixture def mock_batch_serve_to_bq(mock_featurestore): with patch.object(mock_featurestore, "batch_serve_to_bq") as mock_batch_serve_to_bq: yield mock_batch_serve_to_bq @pytest.fixture def mock_batch_create_features(mock_entity_type): with patch.object( mock_entity_type, "batch_create_features" ) as mock_batch_create_features: yield mock_batch_create_features @pytest.fixture def mock_read_feature_values(mock_entity_type): with patch.object(mock_entity_type, "read") as mock_read_feature_values: yield mock_read_feature_values @pytest.fixture def mock_import_feature_values(mock_entity_type): with patch.object( mock_entity_type, "ingest_from_gcs" ) as mock_import_feature_values: yield mock_import_feature_values @pytest.fixture def mock_write_feature_values(mock_entity_type): with patch.object( mock_entity_type, "write_feature_values" ) as mock_write_feature_values: yield mock_write_feature_values @pytest.fixture def mock_feature_online_store(): mock = MagicMock(preview_resources.FeatureOnlineStore) yield mock @pytest.fixture def mock_create_feature_online_store(mock_feature_online_store): with patch.object( preview_resources.FeatureOnlineStore, "create_bigtable_store" ) as mock_create_feature_online_store: mock_create_feature_online_store.return_value = mock_feature_online_store yield mock_create_feature_online_store @pytest.fixture def mock_create_optimized_public_online_store(mock_feature_online_store): with patch.object( preview_resources.FeatureOnlineStore, "create_optimized_store" ) as mock_create_optimized_store: mock_create_optimized_store.return_value = mock_feature_online_store yield mock_create_optimized_store @pytest.fixture def mock_feature_group(): mock = MagicMock(preview_resources.FeatureGroup) yield mock @pytest.fixture def mock_create_feature_group(mock_feature_group): with patch.object( preview_resources.FeatureGroup, "create" ) as mock_create_feature_group: mock_create_feature_group.return_value = mock_feature_group yield mock_create_feature_group @pytest.fixture def mock_get_feature_group(mock_feature_group): with patch.object( preview_resources.FeatureGroup, "__new__" ) as mock_get_feature_group: mock_get_feature_group.return_value = mock_feature_group yield mock_get_feature_group @pytest.fixture def mock_create_optimized_private_online_store(mock_feature_online_store): with patch.object( preview_resources.FeatureOnlineStore, "create_optimized_store" ) as mock_create_optimized_store: mock_create_optimized_store.return_value = mock_feature_online_store yield mock_create_optimized_store @pytest.fixture def mock_get_feature_online_store(mock_feature_online_store): with patch.object( preview_resources.FeatureOnlineStore, "__new__" ) as mock_get_feature_online_store: mock_get_feature_online_store.return_value = mock_feature_online_store yield mock_get_feature_online_store """ ---------------------------------------------------------------------------- Experiment Tracking Fixtures ---------------------------------------------------------------------------- """ @pytest.fixture def mock_execution(): mock = MagicMock(aiplatform.Execution) mock.assign_input_artifacts.return_value = None mock.assign_output_artifacts.return_value = None mock.__enter__.return_value = mock yield mock @pytest.fixture def mock_artifact(): mock = MagicMock(aiplatform.Artifact) yield mock @pytest.fixture def mock_context(): mock = MagicMock(aiplatform.Context) yield mock @pytest.fixture def mock_experiment(): mock = MagicMock(aiplatform.Experiment) yield mock @pytest.fixture def mock_experiment_run(): mock = MagicMock(aiplatform.ExperimentRun) yield mock @pytest.fixture def mock_pipeline_job(): mock = MagicMock(aiplatform.PipelineJob) yield mock @pytest.fixture def mock_df(): mock = MagicMock() yield mock @pytest.fixture def mock_metrics(): mock = MagicMock() yield mock @pytest.fixture def mock_params(): mock = MagicMock() yield mock @pytest.fixture def mock_time_series_metrics(): mock = MagicMock() yield mock @pytest.fixture def mock_classification_metrics(): mock = MagicMock() yield mock @pytest.fixture def mock_artifacts(): mock = MagicMock() yield mock @pytest.fixture def mock_experiment_models(): mock = MagicMock() yield mock @pytest.fixture def mock_model_info(): mock = MagicMock() yield mock @pytest.fixture def mock_ml_model(): mock = MagicMock() yield mock @pytest.fixture def mock_experiment_model(): mock = MagicMock(aiplatform.metadata.schema.google.artifact_schema.ExperimentModel) yield mock @pytest.fixture def mock_get_execution(mock_execution): with patch.object(aiplatform, "Execution") as mock_get_execution: mock_get_execution.return_value = mock_execution yield mock_get_execution @pytest.fixture def mock_execution_get(mock_execution): with patch.object(aiplatform.Execution, "get") as mock_execution_get: mock_execution_get.return_value = mock_execution yield mock_execution_get @pytest.fixture def mock_create_execution(mock_execution): with patch.object(aiplatform.Execution, "create") as mock_create_execution: mock_create_execution.return_value = mock_execution yield mock_create_execution @pytest.fixture def mock_list_execution(mock_execution): with patch.object(aiplatform.Execution, "list") as mock_list_execution: # Returning list of 2 executions to avoid confusion with get method # which returns one unique execution. mock_list_execution.return_value = [mock_execution, mock_execution] yield mock_list_execution @pytest.fixture def mock_get_artifact(mock_artifact): with patch.object(aiplatform, "Artifact") as mock_get_artifact: mock_get_artifact.return_value = mock_artifact yield mock_get_artifact @pytest.fixture def mock_context_get(mock_context): with patch.object(aiplatform.Context, "get") as mock_context_get: mock_context_get.return_value = mock_context yield mock_context_get @pytest.fixture def mock_context_list(mock_context): with patch.object(aiplatform.Context, "list") as mock_context_list: # Returning list of 2 contexts to avoid confusion with get method # which returns one unique context. mock_context_list.return_value = [mock_context, mock_context] yield mock_context_list @pytest.fixture def mock_create_schema_base_context(mock_context): with patch.object( aiplatform.metadata.schema.base_context.BaseContextSchema, "create" ) as mock_create_schema_base_context: mock_create_schema_base_context.return_value = mock_context yield mock_create_schema_base_context @pytest.fixture def mock_artifact_get(mock_artifact): with patch.object(aiplatform.Artifact, "get") as mock_artifact_get: mock_artifact_get.return_value = mock_artifact yield mock_artifact_get @pytest.fixture def mock_pipeline_job_create(mock_pipeline_job): with patch.object(aiplatform, "PipelineJob") as mock_pipeline_job_create: mock_pipeline_job_create.return_value = mock_pipeline_job yield mock_pipeline_job_create @pytest.fixture def mock_artifact_delete(): with patch.object(aiplatform.Artifact, "delete") as mock_artifact_delete: mock_artifact_delete.return_value = None yield mock_artifact_delete @pytest.fixture def mock_execution_delete(): with patch.object(aiplatform.Execution, "delete") as mock_execution_delete: mock_execution_delete.return_value = None yield mock_execution_delete @pytest.fixture def mock_context_delete(): with patch.object(aiplatform.Context, "delete") as mock_context_delete: mock_context_delete.return_value = None yield mock_context_delete @pytest.fixture def mock_pipeline_job_submit(mock_pipeline_job): with patch.object(mock_pipeline_job, "submit") as mock_pipeline_job_submit: mock_pipeline_job_submit.return_value = None yield mock_pipeline_job_submit @pytest.fixture def mock_create_artifact(mock_artifact): with patch.object(aiplatform.Artifact, "create") as mock_create_artifact: mock_create_artifact.return_value = mock_artifact yield mock_create_artifact @pytest.fixture def mock_create_schema_base_artifact(mock_artifact): with patch.object( aiplatform.metadata.schema.base_artifact.BaseArtifactSchema, "create" ) as mock_create_schema_base_artifact: mock_create_schema_base_artifact.return_value = mock_artifact yield mock_create_schema_base_artifact @pytest.fixture def mock_create_schema_base_execution(mock_execution): with patch.object( aiplatform.metadata.schema.base_execution.BaseExecutionSchema, "create" ) as mock_create_schema_base_execution: mock_create_schema_base_execution.return_value = mock_execution |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |