Skip to content

Commit

Permalink
Address PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Nov 8, 2022
1 parent bb2003d commit ed14e80
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lean/commands/data/download.py
Expand Up @@ -287,7 +287,7 @@ def _confirm_payment(organization: QCFullOrganization, products: List[Product])


def _get_organization() -> QCFullOrganization:
"""Gets the working organization/
"""Gets the working organization
:return: The working organization in the current Lean CLI folder
"""
Expand Down
4 changes: 2 additions & 2 deletions lean/commands/lean.py
Expand Up @@ -42,5 +42,5 @@ def lean() -> None:
if organization_manager.get_working_organization_id() is None:
raise RuntimeError(
"This is an old Lean CLI root folder.\n"
"From now on, a Lean CLI root folder must be created for each organization for improved organization.\n"
"Please create a new folder for each organization you are a member of and run `lean init` in it.")
"From now on, a Lean CLI root folder must be created for each organization for improved usability.\n"
"For each organization you'd like to use with the CLI, please create a new folder and run `lean init`.")
2 changes: 1 addition & 1 deletion lean/components/docker/lean_runner.py
Expand Up @@ -183,7 +183,7 @@ def get_basic_docker_config(self,
# Install the required modules when they're needed
if lean_config.get("data-provider", None) == "QuantConnect.Lean.Engine.DataFeeds.DownloaderDataProvider" \
and lean_config.get("data-downloader", None) == "TerminalLinkDataDownloader":
self._module_manager.install_module(TERMINAL_LINK_PRODUCT_ID, lean_config["organization-id"])
self._module_manager.install_module(TERMINAL_LINK_PRODUCT_ID, lean_config["job-organization-id"])

# Force the use of the LocalDisk map/factor providers if no recent zip present and not using ApiDataProvider
data_dir = self._lean_config_manager.get_data_directory()
Expand Down
4 changes: 3 additions & 1 deletion lean/components/util/organization_manager.py
Expand Up @@ -52,7 +52,9 @@ def try_get_working_organization_id(self) -> Optional[str]:
organization_id = self.get_working_organization_id()

if organization_id is None:
raise RuntimeError("The working organization for this Lean CLI folder could not be determined.")
raise RuntimeError(
"The working organization for this Lean CLI folder could not be determined.\n"
"Make sure you run `lean init` on an empty folder for each organization you are a member of")

return organization_id

Expand Down
2 changes: 2 additions & 0 deletions lean/models/lean_config_configurer.py
Expand Up @@ -58,6 +58,8 @@ def configure_credentials(self, lean_config: Dict[str, Any]) -> None:
"""Configures the credentials in the Lean config for this brokerage and saves them persistently to disk.
:param lean_config: the Lean configuration dict to write to
"""
if self._installs:
lean_config["job-organization-id"] = container.organization_manager.try_get_working_organization_id()
for configuration in self._lean_configs:
value = None
if configuration._is_type_configurations_env:
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/test_live.py
Expand Up @@ -536,7 +536,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_brokerage_settings(b
file.write(json.dumps({
**missing_options_config,
"data-folder": "data",
"organization-id": "abc"
"job-organization-id": "abc"
}))

if brokerage == "Binance":
Expand Down Expand Up @@ -601,7 +601,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_data_feed_settings(d
file.write(json.dumps({
**missing_options_config,
"data-folder": "data",
"organization-id": "abc"
"job-organization-id": "abc"
}))

if data_feed == "FTX":
Expand Down Expand Up @@ -651,7 +651,7 @@ def test_live_non_interactive_falls_back_to_lean_config_for_multiple_data_feed_s
file.write(json.dumps({
**missing_options_config,
"data-folder": "data",
"organization-id": "abc"
"job-organization-id": "abc"
}))

if data_feed1 == "FTX" or data_feed2 == "FTX":
Expand Down

0 comments on commit ed14e80

Please sign in to comment.