-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telemetry): add integration tests (#771)
Add integration tests for telemetry ensure that only one event is sent to Heap Analytics per Kedro command --------- Signed-off-by: Dmitry Sorokin <dmd40in@gmail.com> Signed-off-by: Dmitry Sorokin <129520297+DmitrySorokinQB@users.noreply.github.com> Signed-off-by: Nok <nok.lam.chan@quantumblack.com> Co-authored-by: Dmitry Sorokin <129520297+DmitrySorokinQB@users.noreply.github.com> Co-authored-by: Nok <nok.lam.chan@quantumblack.com>
- Loading branch information
1 parent
552b973
commit 4b75db7
Showing
15 changed files
with
399 additions
and
0 deletions.
There are no files selected for viewing
151 changes: 151 additions & 0 deletions
151
kedro-telemetry/tests/integration/dummy-project/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
########################## | ||
# KEDRO PROJECT | ||
|
||
# ignore all local configuration | ||
conf/local/** | ||
!conf/local/.gitkeep | ||
|
||
# ignore potentially sensitive credentials files | ||
conf/**/*credentials* | ||
|
||
# ignore everything in the following folders | ||
data/** | ||
|
||
# except their sub-folders | ||
!data/**/ | ||
|
||
# also keep all .gitkeep files | ||
!.gitkeep | ||
|
||
# keep also the example dataset | ||
!data/01_raw/* | ||
|
||
|
||
########################## | ||
# Common files | ||
|
||
# IntelliJ | ||
.idea/ | ||
*.iml | ||
out/ | ||
.idea_modules/ | ||
|
||
### macOS | ||
*.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
.Trashes | ||
|
||
# Vim | ||
*~ | ||
.*.swo | ||
.*.swp | ||
|
||
# emacs | ||
*~ | ||
\#*\# | ||
/.emacs.desktop | ||
/.emacs.desktop.lock | ||
*.elc | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# C extensions | ||
*.so | ||
|
||
### Python template | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
.static_storage/ | ||
.media/ | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ |
20 changes: 20 additions & 0 deletions
20
kedro-telemetry/tests/integration/dummy-project/conf/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# What is this for? | ||
|
||
This folder should be used to store configuration files used by Kedro or by separate tools. | ||
|
||
This file can be used to provide users with instructions for how to reproduce local configuration with their own credentials. You can edit the file however you like, but you may wish to retain the information below and add your own section in the section titled **Instructions**. | ||
|
||
## Local configuration | ||
|
||
The `local` folder should be used for configuration that is either user-specific (e.g. IDE configuration) or protected (e.g. security keys). | ||
|
||
> *Note:* Please do not check in any local configuration to version control. | ||
## Base configuration | ||
|
||
The `base` folder is for shared configuration, such as non-sensitive and project-related configuration that may be shared across team members. | ||
|
||
WARNING: Please do not put access credentials in the base configuration folder. | ||
|
||
## Find out more | ||
You can find out more about configuration from the [user guide documentation](https://docs.kedro.org/en/stable/configuration/configuration_basics.html). |
Empty file.
Empty file.
Empty file.
34 changes: 34 additions & 0 deletions
34
kedro-telemetry/tests/integration/dummy-project/pyproject.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[build-system] | ||
requires = [ "setuptools",] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "dummy_project" | ||
readme = "README.md" | ||
dynamic = [ "dependencies", "version",] | ||
|
||
[project.scripts] | ||
dummy-project = "dummy_project.__main__:main" | ||
|
||
[tool.kedro] | ||
package_name = "dummy_project" | ||
project_name = "dummy_project" | ||
kedro_init_version = "0.19.6" | ||
tools = [ "None",] | ||
example_pipeline = "True" | ||
source_dir = "src" | ||
|
||
[project.entry-points."kedro.hooks"] | ||
|
||
[tool.setuptools.dynamic.dependencies] | ||
file = "requirements.txt" | ||
|
||
[tool.setuptools.dynamic.version] | ||
attr = "dummy_project.__version__" | ||
|
||
[tool.setuptools.packages.find] | ||
where = [ "src",] | ||
namespaces = false | ||
|
||
[tool.kedro_telemetry] | ||
project_id = "KEDRO_TELEMETRY_TEST" |
9 changes: 9 additions & 0 deletions
9
kedro-telemetry/tests/integration/dummy-project/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ipython>=8.10 | ||
jupyterlab>=3.0 | ||
kedro~=0.19.6 | ||
kedro-datasets[pandas-csvdataset, pandas-exceldataset, pandas-parquetdataset]>=3.0; python_version >= "3.9" | ||
kedro-datasets[pandas.CSVDataset, pandas.ExcelDataset, pandas.ParquetDataset]>=1.0; python_version < "3.9" | ||
kedro-telemetry>=0.3.1 | ||
kedro-viz>=6.7.0 | ||
notebook | ||
scikit-learn~=1.0 |
4 changes: 4 additions & 0 deletions
4
kedro-telemetry/tests/integration/dummy-project/src/dummy_project/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""dummy_project | ||
""" | ||
|
||
__version__ = "0.1" |
47 changes: 47 additions & 0 deletions
47
kedro-telemetry/tests/integration/dummy-project/src/dummy_project/__main__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""dummy_project file for ensuring the package is executable | ||
as `dummy-project` and `python -m dummy_project` | ||
""" | ||
import importlib | ||
from pathlib import Path | ||
|
||
from kedro.framework.cli.utils import KedroCliError, load_entry_points | ||
from kedro.framework.project import configure_project | ||
|
||
|
||
def _find_run_command(package_name): | ||
try: | ||
project_cli = importlib.import_module(f"{package_name}.cli") | ||
# fail gracefully if cli.py does not exist | ||
except ModuleNotFoundError as exc: | ||
if f"{package_name}.cli" not in str(exc): | ||
raise | ||
plugins = load_entry_points("project") | ||
run = _find_run_command_in_plugins(plugins) if plugins else None | ||
if run: | ||
# use run command from installed plugin if it exists | ||
return run | ||
# use run command from the framework project | ||
from kedro.framework.cli.project import run | ||
|
||
return run | ||
# fail badly if cli.py exists, but has no `cli` in it | ||
if not hasattr(project_cli, "cli"): | ||
raise KedroCliError(f"Cannot load commands from {package_name}.cli") | ||
return project_cli.run | ||
|
||
|
||
def _find_run_command_in_plugins(plugins): | ||
for group in plugins: | ||
if "run" in group.commands: | ||
return group.commands["run"] | ||
|
||
|
||
def main(*args, **kwargs): | ||
package_name = Path(__file__).parent.name | ||
configure_project(package_name) | ||
run = _find_run_command(package_name) | ||
run(*args, **kwargs) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
16 changes: 16 additions & 0 deletions
16
kedro-telemetry/tests/integration/dummy-project/src/dummy_project/pipeline_registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Project pipelines.""" | ||
from typing import Dict | ||
|
||
from kedro.framework.project import find_pipelines | ||
from kedro.pipeline import Pipeline | ||
|
||
|
||
def register_pipelines() -> Dict[str, Pipeline]: | ||
"""Register the project's pipelines. | ||
Returns: | ||
A mapping from pipeline names to ``Pipeline`` objects. | ||
""" | ||
pipelines = find_pipelines() | ||
pipelines["__default__"] = sum(pipelines.values()) | ||
return pipelines |
Empty file.
3 changes: 3 additions & 0 deletions
3
...y/tests/integration/dummy-project/src/dummy_project/pipelines/data_processing/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Complete Data Processing pipeline for the spaceflights tutorial""" | ||
|
||
from .pipeline import create_pipeline # NOQA |
9 changes: 9 additions & 0 deletions
9
...y/tests/integration/dummy-project/src/dummy_project/pipelines/data_processing/pipeline.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from kedro.pipeline import Pipeline, node, pipeline | ||
|
||
|
||
def one(): | ||
return "dummy" | ||
|
||
|
||
def create_pipeline(**kwargs) -> Pipeline: | ||
return pipeline([node(one, [], "dummy_output")]) |
46 changes: 46 additions & 0 deletions
46
kedro-telemetry/tests/integration/dummy-project/src/dummy_project/settings.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""Project settings. There is no need to edit this file unless you want to change values | ||
from the Kedro defaults. For further information, including these default values, see | ||
https://docs.kedro.org/en/stable/kedro_project_setup/settings.html.""" | ||
|
||
# Instantiated project hooks. | ||
# For example, after creating a hooks.py and defining a ProjectHooks class there, do | ||
# from dummy_project.hooks import ProjectHooks | ||
|
||
# Hooks are executed in a Last-In-First-Out (LIFO) order. | ||
# HOOKS = (ProjectHooks(),) | ||
|
||
# Installed plugins for which to disable hook auto-registration. | ||
# DISABLE_HOOKS_FOR_PLUGINS = ("kedro-viz",) | ||
|
||
# Class that manages storing KedroSession data. | ||
# from kedro.framework.session.store import BaseSessionStore | ||
# SESSION_STORE_CLASS = BaseSessionStore | ||
# Keyword arguments to pass to the `SESSION_STORE_CLASS` constructor. | ||
# SESSION_STORE_ARGS = { | ||
# "path": "./sessions" | ||
# } | ||
|
||
# Directory that holds configuration. | ||
# CONF_SOURCE = "conf" | ||
|
||
# Class that manages how configuration is loaded. | ||
from kedro.config import OmegaConfigLoader # noqa: E402 | ||
|
||
CONFIG_LOADER_CLASS = OmegaConfigLoader | ||
# Keyword arguments to pass to the `CONFIG_LOADER_CLASS` constructor. | ||
CONFIG_LOADER_ARGS = { | ||
"base_env": "base", | ||
"default_run_env": "local", | ||
# "config_patterns": { | ||
# "spark" : ["spark*/"], | ||
# "parameters": ["parameters*", "parameters*/**", "**/parameters*"], | ||
# } | ||
} | ||
|
||
# Class that manages Kedro's library components. | ||
# from kedro.framework.context import KedroContext | ||
# CONTEXT_CLASS = KedroContext | ||
|
||
# Class that manages the Data Catalog. | ||
# from kedro.io import DataCatalog | ||
# DATA_CATALOG_CLASS = DataCatalog |
Oops, something went wrong.