Skip to content

Commit

Permalink
Merge pull request #226 from rjra2611/bug-fix-allow-compiler-to-setup…
Browse files Browse the repository at this point in the history
…-run-options

Bug fix allow compiler to setup docker run options
  • Loading branch information
Martin-Molinero authored Nov 15, 2022
2 parents 9c96977 + f8885bd commit c508952
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
32 changes: 18 additions & 14 deletions lean/components/docker/lean_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,8 @@ def get_basic_docker_config(self,
"ports": docker_project_config.get("ports", {})
}

# Mount the project directory
run_options["volumes"][str(project_dir)] = {
"bind": "/LeanCLI",
"mode": "rw"
}

# Check if the user has library projects and mount the Library directory
library_dir = self._lean_config_manager.get_cli_root_directory() / "Library"
if library_dir.is_dir():
# Mount the library projects
run_options["volumes"][str(library_dir)] = {
"bind": "/Library",
"mode": "rw"
}
# mount the project and library directories
self.mount_project_and_library_directories(project_dir, run_options)

# Mount the data directory
run_options["volumes"][str(data_dir)] = {
Expand Down Expand Up @@ -729,3 +717,19 @@ def format_error_before_logging(self, chunk: str):

for error in errors:
self._logger.info(error)

def mount_project_and_library_directories(self, project_dir: Path, run_options: Dict[str, Any]) -> None:
# Mount the project directory
run_options["volumes"][str(project_dir)] = {
"bind": "/LeanCLI",
"mode": "rw"
}

# Check if the user has library projects and mount the Library directory
library_dir = self._lean_config_manager.get_cli_root_directory() / "Library"
if library_dir.is_dir():
# Mount the library projects
run_options["volumes"][str(library_dir)] = {
"bind": "/Library",
"mode": "rw"
}
9 changes: 6 additions & 3 deletions lean/components/util/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from json import dumps
from typing import Dict, Any
from lean.container import container
from pathlib import Path

docker_manager = container.docker_manager
project_manager = container.project_manager
Expand Down Expand Up @@ -95,8 +96,10 @@ def _compile() -> Dict[str, Any]:
"algorithmType": "",
}

project_id = int(argv[-1])
project_dir = project_manager.get_project_by_id(project_id)
project_dir = Path(argv[-1])
if not project_dir.exists():
raise(f"Project directory {project_dir} does not exist")

algorithm_file = project_manager.find_algorithm_file(project_dir)
message["algorithmType"] = "python" if algorithm_file.name.endswith(".py") else "csharp"

Expand All @@ -108,7 +111,7 @@ def _compile() -> Dict[str, Any]:
"mounts": [],
"volumes": {}
}

lean_runner.mount_project_and_library_directories(project_dir, run_options)
lean_runner.setup_language_specific_run_options(run_options, project_dir, algorithm_file, False, False)

project_config = project_config_manager.get_project_config(project_dir)
Expand Down

0 comments on commit c508952

Please sign in to comment.