Skip to content

Commit

Permalink
Separate GCP dependencies (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
nweires authored Feb 27, 2024
1 parent 65c8703 commit 11ea6ff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ARG OS_VER
FROM --platform=linux/amd64 nrel/openstudio:$OS_VER as buildstockbatch
ARG CLOUD_PLATFORM=aws

RUN sudo apt update && sudo apt install -y python3-pip
RUN sudo -H pip install --upgrade pip
COPY . /buildstock-batch/
RUN python3 -m pip install "/buildstock-batch"
RUN python3 -m pip install "/buildstock-batch[${CLOUD_PLATFORM}]"

# Base plus custom gems
FROM buildstockbatch as buildstockbatch-custom-gems
Expand Down
4 changes: 3 additions & 1 deletion buildstockbatch/aws/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,9 @@ def build_image(self):
if not (root_path / "Dockerfile").exists():
raise RuntimeError(f"The needs to be run from the root of the repo, found {root_path}")
logger.debug("Building docker image")
self.docker_client.images.build(path=str(root_path), tag=self.docker_image, rm=True)
self.docker_client.images.build(
path=str(root_path), tag=self.docker_image, rm=True, buildargs={"CLOUD_PLATFORM": "aws"}
)

def push_image(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion buildstockbatch/gcp/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def build_image(self):
rm=True,
target=stage,
platform="linux/amd64",
buildargs={"OS_VER": self.os_version},
buildargs={"OS_VER": self.os_version, "CLOUD_PLATFORM": "gcp"},
)
build_image_log = os.path.join(local_log_dir, "build_image.log")
with open(build_image_log, "w") as f_out:
Expand Down
12 changes: 10 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,16 @@ manage BuildStockBatch runs.

1. Install `Docker`_. This is needed by the script to manage Docker images (pull, push, etc).
2. Get BuildStockBatch and set up a Python environment for it using the :ref:`python` instructions
above (i.e., create a Python virtual environment, activate the venv, and install buildstockbatch
to it).
above. (i.e., create a Python virtual environment, activate the venv, and install buildstockbatch
with the command below.)

* Install with the ``[gcp]`` option to include GCP-specific dependencies:

::

cd /path/to/buildstockbatch
python -m pip install -e ".[gcp]"

3. Download/Clone ResStock or ComStock.
4. Set up GCP authentication.

Expand Down
20 changes: 13 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
with open("README.md", "r", "utf-8") as f:
readme = f.read()

gcp_requires = [
"gcsfs",
"google-cloud-artifact-registry",
"google-cloud-batch",
"google-cloud-compute",
"google-cloud-run",
"google-cloud-storage",
"tqdm",
]

setuptools.setup(
name=metadata["__title__"],
version=metadata["__version__"],
Expand Down Expand Up @@ -42,13 +52,6 @@
"awsretry",
"lxml",
"semver",
"gcsfs",
"google-cloud-artifact-registry",
"google-cloud-batch",
"google-cloud-compute",
"google-cloud-run",
"google-cloud-storage",
"tqdm",
],
extras_require={
"dev": [
Expand All @@ -68,6 +71,9 @@
"doc8",
"pre-commit",
]
+ gcp_requires,
"gcp": gcp_requires,
"aws": [],
},
entry_points={
"console_scripts": [
Expand Down

0 comments on commit 11ea6ff

Please sign in to comment.