Skip to content

Commit

Permalink
Added support for dependencies parameter (#80)
Browse files Browse the repository at this point in the history
* Added support for `dependencies` parameter

* Update CHANGELOG.md
  • Loading branch information
SiddhantSadangi authored Feb 16, 2024
1 parent 04a3f03 commit 6ed4b10
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## [UNRELEASED] 0.4.0
## 0.4.0

### Features
- Added [`dependencies`](https://docs.neptune.ai/logging/dependencies/) support ([#80](https://github.com/neptune-ai/kedro-neptune/pull/80))

### Fixes
- Replaced `*DataSet` and `data_set` with `*Dataset` and `dataset` respectively ([#79](https://github.com/neptune-ai/kedro-neptune/pull/79))
Expand Down
16 changes: 15 additions & 1 deletion src/kedro_neptune/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def neptune_commands():
#GLOBAL CONFIG
project: ''
base_namespace: 'kedro'
dependencies: ''
enabled: true
#LOGGING
Expand Down Expand Up @@ -128,8 +129,16 @@ def neptune_commands():
@click.option("--project", prompt=PROMPT_PROJECT_NAME, default="$NEPTUNE_PROJECT")
@click.option("--base-namespace", default="kedro")
@click.option("--config", default="base")
@click.option("--dependencies", default=None)
@click.pass_obj
def init(metadata: ProjectMetadata, api_token: str, project: str, base_namespace: str, config: str):
def init(
metadata: ProjectMetadata,
api_token: str,
project: str,
base_namespace: str,
config: str,
dependencies: str,
):
"""Command line interface (CLI) command for initializing the Kedro-Neptune plugin.
The Kedro-Neptune plugin lets you log metadata related to Kedro pipelines to
Expand Down Expand Up @@ -158,6 +167,9 @@ def init(metadata: ProjectMetadata, api_token: str, project: str, base_namespace
Default is 'kedro'.
config: Name of the subdirectory inside of the Kedro 'conf' directory for
configuration and catalog files. Default is 'base'.
dependencies: Tracks environment requirements.
If you pass "infer" to this argument, Neptune logs dependencies installed in the current environment.
You can also pass a path to your dependency file directly. If left empty, no dependency file is uploaded.
Returns:
`dict` with all summary items.
Expand Down Expand Up @@ -196,6 +208,7 @@ def init(metadata: ProjectMetadata, api_token: str, project: str, base_namespace
config_template["neptune"]["project"] = project
config_template["neptune"]["base_namespace"] = base_namespace
config_template["neptune"]["upload_source_files"] = ["**/*.py", f"{settings.CONF_SOURCE}/{config}/*.yml"]
config_template["neptune"]["dependencies"] = dependencies

yaml.dump(config_template, config_file)

Expand Down Expand Up @@ -251,6 +264,7 @@ def _set_run(self):
capture_hardware_metrics=False,
capture_traceback=False,
source_files=None,
dependencies=neptune_config.dependencies,
)

def _load(self) -> Optional[Handler]:
Expand Down
9 changes: 8 additions & 1 deletion src/kedro_neptune/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class NeptuneConfig:
base_namespace: str
source_files: List[str]
enabled: bool
dependencies: str


def get_neptune_config(settings) -> NeptuneConfig:
Expand All @@ -41,7 +42,13 @@ def get_neptune_config(settings) -> NeptuneConfig:
base_namespace = parse_config_value(config["neptune"]["base_namespace"])
source_files = parse_config_value(config["neptune"]["upload_source_files"])
enabled = ensure_bool(parse_config_value(config["neptune"].get("enabled", True)))
dependencies = parse_config_value(config["neptune"].get("dependencies", None))

return NeptuneConfig(
api_token=api_token, project=project, base_namespace=base_namespace, source_files=source_files, enabled=enabled
api_token=api_token,
project=project,
base_namespace=base_namespace,
source_files=source_files,
enabled=enabled,
dependencies=dependencies,
)

0 comments on commit 6ed4b10

Please sign in to comment.