Skip to content

Commit

Permalink
add python_exe App option; set client in python_runner; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
masalim2 committed Oct 2, 2021
1 parent 09b73e2 commit 056e63f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion balsam/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from balsam.util import config_root_logger

__version__ = "0.7.0.a3"
__version__ = "0.7.0.a4"
config_root_logger()
4 changes: 2 additions & 2 deletions balsam/_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ class ModuleLoadError(Exception):
_default_params: Dict[str, str]
run: Optional[Callable[..., Any]] = None
site: Union[int, str, "Site"]
python_exe: str = sys.executable
_site_id: Optional[int] = None
_client: Optional["RESTClient"] = None
_app_type: AppType
Expand Down Expand Up @@ -251,9 +252,8 @@ def _render_pyrunner_command(self) -> str:
job_payload = self.job._read_model.json()
job_chunks = chunk_str(job_payload, self.ARG_CHUNK_SIZE)

python = sys.executable
args = f"{app_id} {num_app_chunks} {' '.join(app_chunks)} {' '.join(job_chunks)}"
return f"{python} -m balsam.site.launcher.python_runner {args}"
return f"{self.python_exe} -m balsam.site.launcher.python_runner {args}"

def _render_shell_command(self) -> str:
"""
Expand Down
3 changes: 3 additions & 0 deletions balsam/site/launcher/python_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from balsam._api.app import ApplicationDefinition, is_appdef
from balsam._api.models import App, Job
from balsam.config import SiteConfig
from balsam.schemas import SerializeError, serialize, serialize_exception


Expand Down Expand Up @@ -62,9 +63,11 @@ def log_result(ret_val: Any) -> None:


def main(app_id: int, num_app_chunks: int, chunks: List[str]) -> None:
site_config = SiteConfig()
try:
app_cls, job, params = unpack_chunks(app_id, num_app_chunks, chunks)
app = app_cls(job)
app._set_client(site_config.client)
if not callable(app.run):
raise AttributeError(f"ApplicationDefinition {app_cls} does not have a run() function")
return_value = app.run(**params)
Expand Down

0 comments on commit 056e63f

Please sign in to comment.