Generate tailored demo notebooks for each Feast project found nearby. The function searches *repo_path* (default: current working directory) for feature-store YAML files in: * `` /feature_store.yaml`` * Every file inside `` /feast-config/`` For each project
(
output_dir: str = "./feast-demo-notebooks",
repo_path: str = ".",
overwrite: bool = False,
)
| 763 | |
| 764 | |
| 765 | def copy_demo_notebooks( |
| 766 | output_dir: str = "./feast-demo-notebooks", |
| 767 | repo_path: str = ".", |
| 768 | overwrite: bool = False, |
| 769 | ) -> None: |
| 770 | """Generate tailored demo notebooks for each Feast project found nearby. |
| 771 | |
| 772 | The function searches *repo_path* (default: current working directory) for |
| 773 | feature-store YAML files in: |
| 774 | |
| 775 | * ``<repo_path>/feature_store.yaml`` |
| 776 | * Every file inside ``<repo_path>/feast-config/`` |
| 777 | |
| 778 | For each project discovered a sub-directory is created under *output_dir* |
| 779 | and one or more notebooks are written (the exact set depends on the project |
| 780 | configuration and may grow in future releases). |
| 781 | |
| 782 | Parameters |
| 783 | ---------- |
| 784 | output_dir: |
| 785 | Root directory where notebooks are written. |
| 786 | Defaults to ``./feast-demo-notebooks``. |
| 787 | repo_path: |
| 788 | Directory to search for ``feature_store.yaml`` files. |
| 789 | Defaults to the current working directory. |
| 790 | overwrite: |
| 791 | When *False* (default) raise :class:`FileExistsError` if *output_dir* |
| 792 | already exists. Set to *True* to update notebooks in place. |
| 793 | """ |
| 794 | out = pathlib.Path(output_dir).resolve() |
| 795 | |
| 796 | if not overwrite and out.exists(): |
| 797 | raise FileExistsError( |
| 798 | f"Directory '{out}' already exists. " |
| 799 | "Remove it or pass overwrite=True to update notebooks in place." |
| 800 | ) |
| 801 | |
| 802 | root = pathlib.Path(repo_path).absolute() |
| 803 | yaml_paths = _find_feature_store_yamls(root) |
| 804 | |
| 805 | if not yaml_paths: |
| 806 | _logger.warning( |
| 807 | "No feature_store.yaml found under '%s'. " |
| 808 | "Make sure you run this from a directory that contains feature_store.yaml " |
| 809 | "or a feast-config/ subdirectory.", |
| 810 | root, |
| 811 | ) |
| 812 | return |
| 813 | |
| 814 | out.mkdir(parents=True, exist_ok=True) |
| 815 | print(f"Writing demo notebooks to: {out}\n") |
| 816 | |
| 817 | for yaml_path in yaml_paths: |
| 818 | raw = _parse_yaml(yaml_path) |
| 819 | info = _extract_store_info(raw) |
| 820 | project = info["project"] |
| 821 | |
| 822 | project_dir = out / project |