Skip to content

Commit

Permalink
feat(ResearchEnv):added min_ram
Browse files Browse the repository at this point in the history
  • Loading branch information
dweinholz committed Aug 7, 2023
1 parent ca0d7ec commit 92c0a28
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
3 changes: 3 additions & 0 deletions portal_client.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct ResearchEnvironmentTemplate{
7: optional list<string> incompatible_versions,
8: optional bool is_maintained,
9: optional map<string,string> information_for_display
10: optional int min_ram = 0
11: optional int min_cores = 0

}
struct CondaPackage{
1:optional string build,
Expand Down
15 changes: 14 additions & 1 deletion simple_vm_client/forc_connector/template/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
INFORMATION_FOR_DISPLAY = "information_for_display"
NO_TEMPLATE_NAMES = ["packer"]
NEEDS_FORC_SUPPORT = "needs_forc_support"
MIN_RAM = "min_ram"
MIN_CORES = "min_cores"


class ResearchEnvironmentMetadata:
Expand All @@ -41,6 +43,8 @@ def __init__(
protocol: str,
information_for_display: str,
needs_forc_support: bool = True,
min_ram: int = 0,
min_cores: int = 0,
):
self.name = name
self.port = port
Expand All @@ -51,6 +55,8 @@ def __init__(
self.protocol = protocol
self.information_for_display = information_for_display
self.needs_forc_support = needs_forc_support
self.min_ram = min_ram
self.min_cores = min_cores


class Template(object):
Expand Down Expand Up @@ -125,6 +131,8 @@ def update_playbooks(self) -> None:
INFORMATION_FOR_DISPLAY
],
needs_forc_support=True,
min_cores=template_metadata.get(MIN_CORES, 0),
min_ram=template_metadata.get(MIN_RAM, 0),
)
self.update_forc_allowed(template_metadata)
if metadata.name not in list(self._loaded_resenv_metadata.keys()):
Expand Down Expand Up @@ -192,6 +200,8 @@ def add_forc_allowed_template(self, metadata: dict) -> None:
incompatible_versions=metadata["incompatible_versions"],
is_maintained=metadata["is_maintained"],
information_for_display=metadata["information_for_display"],
min_ram=metadata.get("min_ram", 0),
min_cores=metadata.get("min_cores", 0),
)
self._allowed_forc_templates.append(template)

Expand Down Expand Up @@ -238,7 +248,10 @@ def install_ansible_galaxy_requirements(self):
logger.info(output)

def get_allowed_templates(self) -> list[ResearchEnvironmentTemplate]:
logger.info(f"Allowed templates -> {self._allowed_forc_templates}")
logger.info("Allowed templates:")
for template in self._allowed_forc_templates:
logger.info(template)

return self._allowed_forc_templates

def update_forc_allowed(self, template_metadata: dict[str, str]) -> None:
Expand Down
42 changes: 42 additions & 0 deletions simple_vm_client/ttypes.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 92c0a28

Please sign in to comment.