-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bca0852
commit ec690ac
Showing
13 changed files
with
157 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,3 @@ | ||
NPI_CMD_ROOT = $(shell pwd) | ||
GIT_COMMIT = $(shell git log -1 --format='%h' | awk '{print $0}') | ||
DATE = $(shell date +%Y-%m-%d_%H:%M:%S%z) | ||
|
||
VERSION ?= ${GIT_COMMIT} | ||
IMAGE_TAG ?= ${VERSION} | ||
|
||
#os linux or darwin | ||
GOOS ?= darwin | ||
#arch amd64 or arm64 | ||
GOARCH ?= amd64 | ||
|
||
CMD_OUTPUT_DIR ?= ${NPI_CMD_ROOT}/bin | ||
|
||
LD_FLAGS = -X 'main.Version=${VERSION}' | ||
LD_FLAGS += -X 'main.GitCommit=${GIT_COMMIT}' | ||
LD_FLAGS += -X 'main.BuildDate=${DATE}' | ||
LD_FLAGS += -X 'main.Platform=${GOOS}/${GOARCH}' | ||
|
||
GO_BUILD = GOOS=$(GOOS) GOARCH=$(GOARCH) go build -C ${NPI_CMD_ROOT}/cli -trimpath | ||
DOCKER_PLATFORM ?= linux/arm64,linux/amd64 | ||
|
||
build-npi: | ||
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/npi ${NPI_CMD_ROOT}/cli | ||
|
||
release-npi-cli: | ||
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/cli/npi ${NPI_CMD_ROOT}/cli | ||
zip -j ${CMD_OUTPUT_DIR}/npi-${VERSION}-${GOOS}-${GOARCH}.zip ${CMD_OUTPUT_DIR}/npi | ||
|
||
docker-build: | ||
docker buildx build --platform ${DOCKER_PLATFORM} -t npiai/npi:${IMAGE_TAG} . --push | ||
|
||
docker-build-gateway: | ||
docker buildx build --platform linux/amd64 -t npiai/gateway:latest -f build/gateway.Dockerfile proto/go --push | ||
|
||
docker-build-base: | ||
docker buildx build --platform ${DOCKER_PLATFORM} -t npiai/base:3.10 -f build/base.Dockerfile build --push | ||
|
||
docker-build-local: | ||
docker build -t npiai/npi:${IMAGE_TAG} . | ||
|
||
clean: | ||
rm -rf bin | ||
|
||
release: | ||
poetry publish --build -u __token__ -p ${PYPI_TOKEN} | ||
rm -rf dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
NPI_CMD_ROOT = $(shell pwd) | ||
GIT_COMMIT = $(shell git log -1 --format='%h' | awk '{print $0}') | ||
DATE = $(shell date +%Y-%m-%d_%H:%M:%S%z) | ||
|
||
VERSION ?= ${GIT_COMMIT} | ||
IMAGE_TAG ?= ${VERSION} | ||
|
||
#os linux or darwin | ||
GOOS ?= darwin | ||
#arch amd64 or arm64 | ||
GOARCH ?= amd64 | ||
|
||
CMD_OUTPUT_DIR ?= ${NPI_CMD_ROOT}/bin | ||
|
||
LD_FLAGS = -X 'main.Version=${VERSION}' | ||
LD_FLAGS += -X 'main.GitCommit=${GIT_COMMIT}' | ||
LD_FLAGS += -X 'main.BuildDate=${DATE}' | ||
LD_FLAGS += -X 'main.Platform=${GOOS}/${GOARCH}' | ||
|
||
GO_BUILD = GOOS=$(GOOS) GOARCH=$(GOARCH) go build -C ${NPI_CMD_ROOT}/cli -trimpath | ||
DOCKER_PLATFORM ?= linux/arm64,linux/amd64 | ||
|
||
build-npi: | ||
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/npi ${NPI_CMD_ROOT}/cli | ||
|
||
release-npi-cli: | ||
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/cli/npi ${NPI_CMD_ROOT}/cli | ||
zip -j ${CMD_OUTPUT_DIR}/npi-${VERSION}-${GOOS}-${GOARCH}.zip ${CMD_OUTPUT_DIR}/npi | ||
|
||
docker-build: | ||
docker buildx build --platform ${DOCKER_PLATFORM} -t npiai/npi:${IMAGE_TAG} . --push | ||
|
||
docker-build-gateway: | ||
docker buildx build --platform linux/amd64 -t npiai/gateway:latest -f build/gateway.Dockerfile proto/go --push | ||
|
||
docker-build-base: | ||
docker buildx build --platform ${DOCKER_PLATFORM} -t npiai/base:3.10 -f build/base.Dockerfile build --push | ||
|
||
docker-build-local: | ||
docker build -t npiai/npi:${IMAGE_TAG} . | ||
|
||
clean: | ||
rm -rf bin | ||
|
||
release: | ||
poetry publish --build -u __token__ -p ${PYPI_TOKEN} | ||
rm -rf dist |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import sys | ||
import importlib | ||
import time | ||
|
||
|
||
def print_tool_spec(): | ||
# Add the directory containing the file to sys.path | ||
module_dir, module_name = os.path.split('/npiai/tools/app.py') | ||
module_name = os.path.splitext(module_name)[0] # Remove the .py extension | ||
|
||
if module_dir not in sys.path: | ||
sys.path.append(module_dir) | ||
|
||
# Now you can import the module using its name | ||
module = importlib.import_module(module_name) | ||
# Create an instance of the class | ||
tool_class = getattr(module, 'GitHub') | ||
instance = tool_class() | ||
print(instance.export()) | ||
|
||
|
||
async def main(): | ||
# Add the directory containing the file to sys.path | ||
module_dir, module_name = os.path.split('app.py') | ||
module_name = os.path.splitext(module_name)[0] # Remove the .py extension | ||
|
||
if module_dir not in sys.path: | ||
sys.path.append(module_dir) | ||
|
||
# Now you can import the module using its name | ||
module = importlib.import_module(module_name) | ||
# Create an instance of the class | ||
tool_class = getattr(module, 'GitHub') | ||
instance = tool_class() | ||
|
||
async with instance as i: | ||
# await i.wait() TODO add this method to BaseApp class | ||
time.sleep(1000) | ||
|
||
if __name__ == '__main__': | ||
print_tool_spec() |
Oops, something went wrong.