Skip to content

Commit

Permalink
Create nv-ingest-api wheel and publish nightly to artifactory (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdye64 authored Feb 11, 2025
1 parent efcb7ae commit 0ac0593
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 14 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/pypi-nightly-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,19 @@ jobs:
run: |
pip install build twine
- name: Build wheel
- name: Build nv-ingest-api wheel
run: |
cd api && python -m build
- name: Build nv-ingest-client wheel
run: |
cd client && python -m build
- name: Publish to Artifactory
- name: Publish wheels to Artifactory
env:
ARTIFACTORY_URL: ${{ secrets.ARTIFACTORY_URL }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: |
twine upload --repository-url $ARTIFACTORY_URL -u $ARTIFACTORY_USERNAME -p $ARTIFACTORY_PASSWORD client/dist/*
twine upload --repository-url $ARTIFACTORY_URL -u $ARTIFACTORY_USERNAME -p $ARTIFACTORY_PASSWORD api/dist/* \
&& twine upload --repository-url $ARTIFACTORY_URL -u $ARTIFACTORY_USERNAME -p $ARTIFACTORY_PASSWORD client/dist/*
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ RUN if [ -z "${VERSION}" ]; then \

ENV NV_INGEST_RELEASE_TYPE=${RELEASE_TYPE}
ENV NV_INGEST_VERSION_OVERRIDE=${NV_INGEST_VERSION_OVERRIDE}
ENV NV_INGEST_CLIENT_VERSION_OVERRIDE=${NV_INGEST_VERSION_OVERRIDE}

SHELL ["/bin/bash", "-c"]

COPY tests tests
COPY data data
COPY api api
COPY client client
COPY src/nv_ingest src/nv_ingest
RUN rm -rf ./src/nv_ingest/dist ./client/dist
RUN rm -rf ./src/nv_ingest/dist ./client/dist ./api/dist

# Install python build from pip, version needed not present in conda
RUN source activate nv_ingest_runtime \
Expand All @@ -100,13 +100,15 @@ RUN --mount=type=cache,target=/opt/conda/pkgs \
--mount=type=cache,target=/root/.cache/pip \
chmod +x ./ci/scripts/build_pip_packages.sh \
&& source activate nv_ingest_runtime \
&& ./ci/scripts/build_pip_packages.sh --type ${RELEASE_TYPE} --lib api \
&& ./ci/scripts/build_pip_packages.sh --type ${RELEASE_TYPE} --lib client \
&& ./ci/scripts/build_pip_packages.sh --type ${RELEASE_TYPE} --lib service

RUN --mount=type=cache,target=/opt/conda/pkgs\
--mount=type=cache,target=/root/.cache/pip \
source activate nv_ingest_runtime \
&& pip install ./dist/*.whl \
&& pip install ./api/dist/*.whl \
&& pip install ./client/dist/*.whl

RUN rm -rf src
Expand Down
7 changes: 7 additions & 0 deletions api/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exclude *.egg-info

include README.md
include LICENSE
recursive-include src *
global-exclude __pycache__
global-exclude *.pyc
7 changes: 5 additions & 2 deletions api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[build-system]
requires = ["setuptools", "wheel"] # Tools needed to build the project
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "nv-ingest-api"
version = "24.12.dev0"
description = "Python module with core document ingestion functions."
dynamic = ["version"] # Declare attrs that will be generated at build time
readme = "README.md"
authors = [
{name = "Jeremy Dyer", email = "[email protected]"}
Expand All @@ -29,3 +29,6 @@ documentation = "https://docs.nvidia.com/nv-ingest"

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.dynamic]
version = {attr = "version.get_version"}
36 changes: 36 additions & 0 deletions api/src/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES.
# All rights reserved.
# SPDX-License-Identifier: Apache-2.0


import datetime
import os
import re


def get_version():
release_type = os.getenv("NV_INGEST_RELEASE_TYPE", "dev")
version = os.getenv("NV_INGEST_VERSION")
rev = os.getenv("NV_INGEST_REV", "0")

if not version:
version = f"{datetime.datetime.now().strftime('%Y.%m.%d')}"

# Ensure the version is PEP 440 compatible
pep440_regex = r"^\d{4}\.\d{1,2}\.\d{1,2}$"
if not re.match(pep440_regex, version):
raise ValueError(f"Version '{version}' is not PEP 440 compatible")

# Construct the final version string
if release_type == "dev":
# If rev is not specified and defaults to 0 lets create a more meaningful development
# identifier that is pep440 compliant
if int(rev) == 0:
rev = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
final_version = f"{version}.dev{rev}"
elif release_type == "release":
final_version = f"{version}.post{rev}" if int(rev) > 0 else version
else:
raise ValueError(f"Invalid release type: {release_type}")

return final_version
17 changes: 11 additions & 6 deletions ci/scripts/build_pip_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Function to display usage
usage() {
echo "Usage: $0 --type <dev|release> --lib <client|service>"
echo "Usage: $0 --type <dev|release> --lib <api|client|service>"
exit 1
}

Expand Down Expand Up @@ -38,11 +38,16 @@ else
fi

# Set library-specific variables and paths
if [[ "$LIBRARY" == "client" ]]; then
NV_INGEST_CLIENT_VERSION_OVERRIDE="${VERSION_SUFFIX}"
export NV_INGEST_CLIENT_VERSION_OVERRIDE
SETUP_PATH="$SCRIPT_DIR/../../client"
(cd "$(dirname "$SETUP_PATH")/client" && python -m build)
if [[ "$LIBRARY" == "api" ]]; then
NV_INGEST_VERSION_OVERRIDE="${VERSION_SUFFIX}"
export NV_INGEST_VERSION_OVERRIDE
SETUP_PATH="$SCRIPT_DIR/../../api/pyproject.toml"
(cd "$(dirname "$SETUP_PATH")" && python -m build)
elif [[ "$LIBRARY" == "client" ]]; then
NV_INGEST_VERSION_OVERRIDE="${VERSION_SUFFIX}"
export NV_INGEST_VERSION_OVERRIDE
SETUP_PATH="$SCRIPT_DIR/../../client/pyproject.toml"
(cd "$(dirname "$SETUP_PATH")" && python -m build)
elif [[ "$LIBRARY" == "service" ]]; then
NV_INGEST_SERVICE_VERSION_OVERRIDE="${VERSION_SUFFIX}"
export NV_INGEST_SERVICE_VERSION_OVERRIDE
Expand Down
2 changes: 1 addition & 1 deletion client/src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def get_version():
release_type = os.getenv("NV_INGEST_RELEASE_TYPE", "dev")
version = os.getenv("NV_INGEST_CLIENT_VERSION")
version = os.getenv("NV_INGEST_VERSION")
rev = os.getenv("NV_INGEST_REV", "0")

if not version:
Expand Down

0 comments on commit 0ac0593

Please sign in to comment.