Skip to content

Commit

Permalink
Merge pull request #119 from rjra2611/feature-store-backtest-name-in-…
Browse files Browse the repository at this point in the history
…config

Add utility methods for local vscode plugin
  • Loading branch information
Martin-Molinero authored Aug 9, 2022
2 parents 5e95554 + f096b92 commit c8189f0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lean/components/config/output_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,32 @@ def get_backtest_id(self, backtest_directory: Path) -> int:
"""
return self._get_id(backtest_directory, 1)

def get_backtest_name(self, backtest_directory: Path) -> int:
"""Returns the name of a backtest.
:param backtest_directory: the path to the backtest to retrieve the id of
:return: the name of the given backtest
"""
config = self.get_output_config(backtest_directory)

if config.has("backtest-name"):
return config.get("backtest-name")

raise ValueError("Backtest name is not set")

def get_container_name(self, backtest_directory: Path) -> int:
"""Returns the name of a the docker container lean is running in.
:param backtest_directory: the path to the backtest to retrieve the id of
:return: the name of the docker container lean is running in.
"""
config = self.get_output_config(backtest_directory)

if config.has("container"):
return config.get("container")

raise ValueError("Container name is not set")

def get_backtest_by_id(self, backtest_id: int, root_directory: Optional[Path] = None) -> Path:
"""Finds the directory of a backtest by its id.
Expand Down
2 changes: 2 additions & 0 deletions lean/components/docker/lean_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ def get_basic_docker_config(self,
run_options["name"] = f"lean_cli_{str(uuid.uuid4()).replace('-', '')}"
output_config = self._output_config_manager.get_output_config(output_dir)
output_config.set("container", run_options["name"])
if "backtest-name" in lean_config:
output_config.set("backtest-name", lean_config["backtest-name"])

if "environment" in lean_config and "environments" in lean_config:
environment = lean_config["environments"][lean_config["environment"]]
Expand Down

0 comments on commit c8189f0

Please sign in to comment.