-
Notifications
You must be signed in to change notification settings - Fork 24
feat(api): image building process improvement #404
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
base: main
Are you sure you want to change the base?
Conversation
…python on the app.Dockerfile instead
…on app.Dockerfile
00c1d89
to
65f9d3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for all the refactoring and testing work gone into this PR! 🚀🙏🏼 Most of it looks good but I just left a couple of small comments here and there (the comments on the ensembler job stuff generally apply to the ensembler server stuff too). Feel free to merge this PR once you've addressed the comments!
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it's alright to keep this, so that we perform unit tests of the pyfunc ensembler job/service for different versions of Python 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
workflow_run: | ||
workflows: ["sdk"] | ||
types: | ||
- completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this is cool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I can't test this until the workflow is merged to main tho, hopefully it runs as expected
|| ( github.event_name != 'pull_request' ) | ||
|| ( github.event.pull_request.head.repo.full_name == github.repository ) | ||
|| ( github.event.pull_request.head.repo.full_name == github.repository )) && | ||
${{ github.event.workflow_run.conclusion == 'success' }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, github.event.workflow_run
refers to the SDK workflow right? If it is, then wouldn't the on.workflow_run.workflows
thing you configured at the top of this file already guarantee that the workflow needs to be successful before this entire workflow can even begin running? 🤔 In other words, would ${{ github.event.workflow_run.conclusion == 'success' }}
be redundant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workflow_run:
workflows: ["sdk"]
types:
- completed
the completed
in here doesn't check whether the conclusion
of the workflow is success
or failure
, therefore I need to check the conclusion manually. The example on the documentation suggests that it work like that. Maybe my comment above the workflow_run
is confusing
run: | | ||
set -o pipefail | ||
make build-and-publish | tee output.log | ||
echo "pyfunc-ensembler-job=$(sed -n 's%Building docker image: \(.*\)%\1%p' output.log)" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, why do we need to store this as a GitHub output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember my reason on doing this haha, maybe because the Build Docker Image
job saves the log to the output, I also save this job's log to the output. But if it isn't necessary I can delete this part. And setting the output using ::set-output
is deprecated and they ask us to setting it using >> $GITHUB_OUTPUT
artifactServiceType string | ||
artifactService artifact.Service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can simplify this struct by removing the artifactServiceType
field because it is the same as artifactService.GetType()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I missed that, thanks. Updated
tt.artifactURI, | ||
testArtifactURI, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol thanks for realising that tt.artifactURI
is the same for all test cases and for replacing it with a single re-usable variable instead.
# Install yq | ||
ENV YQ_VERSION=v4.42.1 | ||
RUN wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && \ | ||
chmod +x /usr/bin/yq | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ultra nit: can we move this up above the block that installs the gcloud SDK? So it looks similar to the Dockerfile found in Merlin? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahaha sure no problem, updated!
setup: $(CONDA_ENV_NAME) | ||
$(CONDA_ENV_NAME): | ||
@conda env update -f env-$(PYTHON_VERSION).yaml -n $(CONDA_ENV_NAME) --prune | ||
$(ACTIVATE_ENV) && pip install -r requirements.dev.txt | ||
setup: build | ||
@pip install pipenv | ||
@DIST_VERSION=$$(echo $(VERSION) | \ | ||
sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+)(-rc([0-9]+))?/\1rc\3/'); \ | ||
pipenv run pip install "dist/turing_pyfunc_ensembler_job-$${DIST_VERSION}-py3-none-any.whl[dev]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, did you change all the conda virtual env stuff to pipenv to follow Merlin's implementation? I was thinking if it was possible to just keep all the conda-related stuff 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea I think I tried to mimic how merlin does this and they use pipenv
to do this. Should I rewrite it to use conda ?
@@ -5,3 +5,4 @@ mypy>=0.910 | |||
pytest<=8.1.2 | |||
pytest-cov | |||
pylint | |||
types-PyYAML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh where is this used? :o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I remember having an error saying types-PyYAML
is not found, but I just retested it and it works fine now. Removed
# get version from version.py | ||
spec = importlib.util.spec_from_file_location( | ||
"pyfuncserver.version", os.path.join("version.py") | ||
) | ||
|
||
v_module = importlib.util.module_from_spec(spec) | ||
spec.loader.exec_module(v_module) | ||
|
||
version = v_module.VERSION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa this looks complex 😅 Can't we retrieve the version in a simpler way like this https://github.com/caraml-dev/turing/blob/main/sdk/setup.py#L5? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
python-version: "3.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intended to 3.10 and why are we still hard coded this specific version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to put a python version here that we will use to do the testing, no specific reason on why I choose 3.10 tho haha. But it will be reverted to apply Zi's comment https://github.com/caraml-dev/turing/pull/404/files/69419b6ebed4ebbd1c8c1ab0167b30d2395fe352#r2053718016
@@ -94,6 +95,8 @@ func NewAppContext( | |||
// Init ensemblers service | |||
ensemblersService := service.NewEnsemblersService(db) | |||
|
|||
artifactService, err := initArtifactService(cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, it this expected that the error isn't being handled? 😮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this 🤝, updated
… get artifact service type
Context
This PR contains improvement for
pyfunc-ensembler-service
/pyfunc-ensembler-job
image building process. This improvement removes the need of supporting specific python versions and use the python version specified in user dependency instead, similar on how merlin buildspyfunc-server
andbatch-predictor
images.Changes in this PR includes improvement for the imagebuilder,
pyfunc-ensembler-service
/pyfunc-ensembler-job
package, and little bit ofsdk
.imagebuilder
pyfunc-ensembler-service
/pyfunc-ensembler-job
dependency to user's conda.yaml.conda.yaml
to prevent the URL value ofconda.yaml
that has the same content to change and invalidating docker layer cache.pyfunc-ensembler-service
/pyfunc-ensembler-job
packagesdk
workflow is run successfully.pyfunc-ensembler-service
/pyfunc-ensembler-job
share the same version withturing-sdk
package, but both of these package requires latestturing-sdk
version, so we need to run the workflow only aftersdk
workflow completed.sdk
sdk
workflow topython/*
tag push instead ofsdk/*
tag push.python/*
tag and version will be used byturing-sdk
,pyfunc-ensembler-service
andpyfunc-ensembler-job
packages.Main Modifications
imagebuilder/imagebuilder.go
:--build-arg=BASE_IMAGE=%s
valueconda.yaml
engines/pyfunc-ensembler-*/Makefile
:pyfunc-ensembler-*
packageengines/pyfunc-ensembler-*/app.Dockerfile
:turing-pyfunc-ensembler-*
to user's dependency.github/workflows/*
python/*
tag assdk
workflow triggerspyfunc-ensembler-*
workflow aftersdk
workflow is run successfully