Skip to content

Commit

Permalink
Fixed pager duty
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsinai committed Jun 29, 2023
1 parent efe0dcc commit 0a16347
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 61 deletions.
Binary file removed .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ venv/
**/.idea/modules.xml
**/.idea/vcs.xml
**/.idea/.gitignore
**/.idea/workspace.xml
**/.idea/workspace.xml
.DS_Store
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ endef

# Install dependencies
install:
$(call deactivate_virtualenv) && \
$(call install_poetry) && \
poetry install --with dev --all-extras

Expand Down
4 changes: 1 addition & 3 deletions integrations/pager-duty/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
../../../../.vscode/
assets/
venv/
*.md
.git
.gitignore
.env
config.yaml
.env
6 changes: 3 additions & 3 deletions integrations/pager-duty/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ ENV LIBRDKAFKA_VERSION 1.9.2

WORKDIR /app

RUN apt update && apt install -y wget make g++ libssl-dev autoconf automake libtool
RUN apt update && apt install -y wget make g++ libssl-dev autoconf automake libtool curl
RUN wget https://github.com/edenhill/librdkafka/archive/v${LIBRDKAFKA_VERSION}.tar.gz && \
tar xvzf v${LIBRDKAFKA_VERSION}.tar.gz && \
(cd librdkafka-${LIBRDKAFKA_VERSION}/ && ./configure && make && make install && ldconfig)

COPY . /app

RUN make install-release
RUN make install

ENTRYPOINT poetry run ocean sail
ENTRYPOINT make run
74 changes: 50 additions & 24 deletions integrations/pager-duty/Makefile
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
SHELL := /bin/bash
ACTIVATE := . venv/bin/activate
ACTIVATE := . .venv/bin/activate

venv:
@if [ ! -d "./venv" ]; then \
python3 -m venv "venv"; \
fi
define run_lint
exit_code=0; \
cd $1; \
mypy . --exclude '/venv/' || exit_code=$$?; \
ruff . || exit_code=$$?; \
black --exclude venv --check . || exit_code=$$?; \
if [ $$exit_code == 1 ]; then \
echo -e "\033[0;31mOne or more lints failed with exit code $$exit_code\033[0m"; \
else \
echo -e "\033[0;32mAll lints executed successfully.\033[0m"; \
fi; \
exit $$exit_code
endef

generate_config:
@if [[ ! -e .env ]]; then \
cp example.config.yaml config.yaml; \
define install_poetry
if ! command -v poetry &> /dev/null; then \
echo "Poetry is not installed. Installing..."; \
curl -sSL https://install.python-poetry.org | python3 -; \
else \
echo "Poetry is already installed."; \
fi
endef

install: venv generate_config
$(ACTIVATE) && \
pip install --upgrade pip && \
pip install poetry && \
poetry install --with dev --all-extras
define deactivate_virtualenv
if [ -n "$$VIRTUAL_ENV" ]; then \
unset VIRTUAL_ENV; \
unset PYTHONHOME; \
unset -f pydoc >/dev/null 2>&1; \
OLD_PATH="$$PATH"; \
PATH=$$(echo -n "$$PATH" | awk -v RS=: -v ORS=: '/\/virtualenv\/bin$$/ {next} {print}'); \
export PATH; \
hash -r; \
echo "Deactivated the virtual environment."; \
fi
endef

.SILENT: install lint run test clean

install-release:
pip install --upgrade pip && \
pip install poetry && \
poetry install --with dev --all-extras

mypy:
$(ACTIVATE) && mypy ./port_ocean

run: mypy
$(ACTIVATE) && poetry run main.py
install:
$(call deactivate_virtualenv) && \
$(call install_poetry) && \
poetry install --with dev

lint:
$(ACTIVATE) && \
$(call run_lint,.)

run:
$(ACTIVATE) && ocean sail

test: mypy
test: lint
$(ACTIVATE) && poetry run pytest

clean:
@find . -name '.venv' -type d -exec rm -rf {} \;
@find . -name '*.pyc' -exec rm -rf {} \;
@find . -name '__pycache__' -exec rm -rf {} \;
@find . -name 'Thumbs.db' -exec rm -rf {} \;
Expand All @@ -42,4 +68,4 @@ clean:
rm -rf htmlcov
rm -rf .tox/
rm -rf docs/_build
rm -rf venv/
rm -rf dist/
4 changes: 2 additions & 2 deletions integrations/pager-duty/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pager_duty
# pager-duty

Pager duty integration for port
A short description of the project

## Development Requirements

Expand Down
2 changes: 1 addition & 1 deletion integrations/pager-duty/example.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ integration:
# The configuration of the integration.
# resyncOnStartup: true
config:
bootstrapServers: "localhost:9092"
bootstrapServers: "localhost:9092"
5 changes: 0 additions & 5 deletions integrations/pager-duty/integration.py

This file was deleted.

8 changes: 4 additions & 4 deletions integrations/pager-duty/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions integrations/pager-duty/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[virtualenvs]
create = true
in-project = true
37 changes: 32 additions & 5 deletions integrations/pager-duty/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[tool.poetry]
name = "pager_duty"
name = "pager-duty"
version = "0.1.0"
description = "Pager duty integration for port"
authors = ["daniel sinai <daniel@getport.io>"]
description = "A short description of the project"
authors = ["Your name <Your address email <you@example.com>>"]

[tool.poetry.dependencies]
python = "^3.11"
port_ocean = {version = "0.1.0.dev2", extras = ["cli"]}
port_ocean = { version = "^0.1.0.dev2", extras = ["cli"] }

[tool.poetry.group.dev.dependencies]
pytest = "^7.2"
Expand All @@ -18,17 +18,44 @@ pylint = "^2.17.4"
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

[tool.mypy]
plugins = [
"pydantic.mypy"
]

follow_imports = "silent"
warn_redundant_casts = true
warn_unused_ignores = true
disallow_any_generics = true
check_untyped_defs = true
no_implicit_reexport = true

# for strict mypy: (this is the tricky one :-))
disallow_untyped_defs = true


[tool.ruff]
# Never enforce `E501` (line length violations).
ignore = ["E501"]

[tool.pydantic-mypy]
init_forbid_extra = true
init_typed = true
warn_required_dynamic_aliases = true
warn_untyped_fields = true

[tool.black]
line-length = 88
target-version = ['py39', 'py310', 'py311']
include = '\.pyi?$'
exclude = '''
/(
\scripts
\.toml
|\.sh
|\.git
|\.ini
|\.venv
|Dockerfile
|Jenkinfile
)/
'''
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
FROM python:3.10-slim-buster
FROM python:3.11-slim-buster

ENV LIBRDKAFKA_VERSION 1.9.2

WORKDIR /app

RUN apt update && apt install -y wget make g++ libssl-dev
RUN apt update && apt install -y wget make g++ libssl-dev autoconf automake libtool curl
RUN wget https://github.com/edenhill/librdkafka/archive/v${LIBRDKAFKA_VERSION}.tar.gz && \
tar xvzf v${LIBRDKAFKA_VERSION}.tar.gz && \
(cd librdkafka-${LIBRDKAFKA_VERSION}/ && ./configure && make && make install && ldconfig)

COPY . /app

ENV CONFIG_PATH /app/config.yaml
RUN make install


RUN chmod +x ./deployment/docker/install_req.sh
RUN ./deployment/docker/install_req.sh
RUN pip3 install confluent-kafka

ENTRYPOINT python3 main.py --integrations-config=$CONFIG_PATH
ENTRYPOINT make run
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["{{cookiecutter.full_name}} <{{cookiecutter.email}}>"]

[tool.poetry.dependencies]
python = "^3.11"
port_ocean = { version = "^0.1.0.dev2", extras = ["cli"] }
port_ocean = { version = "^0.1.0.dev3", extras = ["cli"] }

[tool.poetry.group.dev.dependencies]
pytest = "^7.2"
Expand Down
2 changes: 1 addition & 1 deletion port_ocean/core/handlers/port_app_config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class EntityMapping(BaseModel):
identifier: str
title: str
title: str | None
blueprint: str
properties: dict[str, str] = Field(default_factory=dict)
relations: dict[str, str] = Field(default_factory=dict)
Expand Down
2 changes: 1 addition & 1 deletion port_ocean/core/integrations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def _sync_new_in_batches(

tasks = []

batch_size = self.context.config.batch_work_size or len(results)
batch_size = self.context.config.batch_work_size or len(results) or 1
for batch in [
results[i : i + batch_size] for i in range(0, len(results), batch_size)
]:
Expand Down

0 comments on commit 0a16347

Please sign in to comment.