Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't Install Tableau API on arm64 #218

Merged
merged 3 commits into from
Jan 11, 2024
Merged

Don't Install Tableau API on arm64 #218

merged 3 commits into from
Jan 11, 2024

Conversation

mzappitello
Copy link
Contributor

The tableauhyperapi module is unavailable on mac with arm64 processors.

  • Update poetry to take advantage of dependency groups.
  • Add a tableau dependency group that can be excluded when installing dependencies.
  • Update python_src to fallback with error messages when using the tableau subdir that creates hyperfiles fails to import everything.
  • Use new BUILDPLATFORM arg in dockerfile to build without tableau deps on an arm64 platform.
  • Add an export for the BUILDPLATFORM variable to .envrc and pass it through via docker-compose when building the lamp py images.

Asana Task: <asana_ticket_url>

.envrc Outdated
Comment on lines 5 to 6
export BUILDPLATFORM=$(uname -m)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is passed to docker compose, which passes it to the dockerfile, which uses it to install tableau deps or not.

Comment on lines 22 to 23
args:
BUILDPLATFORM: $BUILDPLATFORM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass arg to dockerfile which is used to install poetry or not.

Comment on lines 26 to 33
# Tableau dependencies for arm64 cannot be resolved (since salesforce doesn't
# support them yet). For that buildplatform build without those dependencies
ARG BUILDPLATFORM
RUN echo "Installing python dependencies for ${BUILDPLATFORM}."
RUN if [ "$BUILDPLATFORM" = "arm64" ]; then \
poetry install --without tableau --no-interaction --no-ansi -v ;\
else poetry install --no-interaction --no-ansi -v ;\
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its an arm64 build platform, install without the tableau dep group.

@@ -27,10 +27,15 @@ psutil = "^5.9.1"
schedule = "^1.1.0"
alembic = "^1.10.2"
types-pytz = "^2023.3.0.1"

[tool.poetry.group.tableau]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add dependency group for tableau dependencies. its not optional, meaning a user will have to change behavior to build without it.

@@ -1 +1,21 @@
"""Utilites for Interacting with Tableau and Hyper files"""
"""Utilities for Interacting with Tableau and Hyper files"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update the tableau init file to catch exceptions when the tableau modues arent found.

from lamp_py.tableau.pipeline import start_parquet_updates
from lamp_py.tableau import start_parquet_updates
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only part i don't like. if we import directly from the file we're doing to get the import error and it felt like catch that error should be left to the subdir.

The tableauhyperapi module is unavailable on mac with arm64 processors.

* Update poetry to take advantage of dependency groups.
* Add a tableau dependency group that can be excluded when installing
  dependencies.
* Update python_src to fallback with error messages when using the
  tableau subdir that creates hyperfiles fails to import everything.
* Use new `BUILDPLATFORM` arg in dockerfile to build without tableau
  deps on an arm64 platform.
* Add an export for the BUILDPLATFORM variable to .envrc and pass it
  through via docker-compose when building the lamp py images.
Copy link
Collaborator

@rymarczy rymarczy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks like it's functioning as expected for me locally.

I think we need to add some documentation regarding why/how we are doing this in a README file. We are also missing a README for the "tableau" applications, which is my oversight when originally adding that functionality.

@paulswartz Could you also please review this approach and see if you can find any potential issues with this approach? Are any other TID apps doing anything similar with a different approach?

.envrc Outdated

# used in dockercompose and dockerfile
export BUILDPLATFORM=$(uname -m)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Do you need to set this? At least according to the Docker documentation this should be provided already.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried this out locally based on this same documentation and found that the value evaluated to an empty string when I ran on my machine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff worked for me without needing to set any additional variables:

diff --git a/python_src/Dockerfile b/python_src/Dockerfile
index 06a3e1e..40d69a6 100644
--- a/python_src/Dockerfile
+++ b/python_src/Dockerfile
@@ -25,9 +25,9 @@ COPY pyproject.toml pyproject.toml

 # Tableau dependencies for arm64 cannot be resolved (since salesforce doesn't
 # support them yet). For that buildplatform build without those dependencies
-ARG BUILDPLATFORM
-RUN echo "Installing python dependencies for ${BUILDPLATFORM}."
-RUN if [ "$BUILDPLATFORM" = "arm64" ]; then \
+ARG TARGETARCH BUILDPLATFORM TARGETPLATFORM
+RUN echo "Installing python dependencies for build: ${BUILDPLATFORM} target: ${TARGETPLATFORM}"
+RUN if [ "$TARGETARCH" = "arm64" ]; then \
     poetry install --without tableau --no-interaction --no-ansi -v ;\
     else poetry install --no-interaction --no-ansi -v ;\
     fi

@@ -1 +1,29 @@
"""Utilites for Interacting with Tableau and Hyper files"""
"""Utilities for Interacting with Tableau and Hyper files"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion(non-blocking):

try:
  import .pipeline as pipeline
except ModuleNotFoundError:
  pipeline = None

def start_parquet_updates(db_manager: DatabaseManager) -> None
  if pipeline is None:
    logging.exception(...)
  else:
    pipeline.start_parquet_updates(db_manager)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. i like this much better.

@mzappitello mzappitello force-pushed the tableau_build_args branch 2 times, most recently from 20fcbba to fa19ad6 Compare January 11, 2024 15:26
* Change some of the details in the tableau __init__ file.
* No need to pass in build platform arg. remove from direnv and
  docker-compose.
Copy link
Collaborator

@rymarczy rymarczy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, working locally for me.

@mzappitello mzappitello merged commit 471e2d2 into main Jan 11, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants