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

Port 10639 add memray to jira integration #1050

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
276f23a
Add memray to jira integration
talsabagport Sep 26, 2024
3dfd3ee
Add memray to jira integration
talsabagport Sep 26, 2024
0bfdab2
use memray in dockerfile
talsabagport Sep 26, 2024
b3b421b
use memray in dockerfile
talsabagport Sep 26, 2024
d9763c7
Merge branch 'main' of github.com:port-labs/Port-Ocean into PORT-1063…
yairsimantov20 Sep 29, 2024
4428c6c
delete memray file
yairsimantov20 Sep 29, 2024
8c6901f
delete memray file
yairsimantov20 Sep 29, 2024
389cbfb
Memray aggregate
talsabagport Sep 29, 2024
c170bbd
Merge branch 'main' of github.com:port-labs/Port-Ocean into PORT-1063…
yairsimantov20 Oct 1, 2024
a5e5ff3
ocean 0.12.0
yairsimantov20 Oct 1, 2024
8903605
revert init
yairsimantov20 Oct 1, 2024
7ceae25
jira with malocs
yairsimantov20 Oct 1, 2024
70113c8
Merge remote-tracking branch 'origin/PORT-10639-add-memray-to-jira-in…
yairsimantov20 Oct 1, 2024
018328d
jira with malocs
yairsimantov20 Oct 1, 2024
7adbbbd
jira with malocs
yairsimantov20 Oct 1, 2024
1890433
jira with malocs
yairsimantov20 Oct 1, 2024
b54c291
jira with malocs
yairsimantov20 Oct 1, 2024
267bdb1
jira with malocs
yairsimantov20 Oct 1, 2024
7dade83
jira with malocs
yairsimantov20 Oct 1, 2024
339ac1d
removed memray
yairsimantov20 Oct 1, 2024
e0d4a3e
Merge branch 'main' of github.com:port-labs/Port-Ocean into PORT-1063…
yairsimantov20 Oct 2, 2024
762757f
lockfile
yairsimantov20 Oct 2, 2024
04edf9d
lockfile
yairsimantov20 Oct 2, 2024
a853c83
lockfile
yairsimantov20 Oct 2, 2024
f62ff07
lockfile
yairsimantov20 Oct 2, 2024
f27f9d7
lockfile
yairsimantov20 Oct 2, 2024
d4c837c
threadpool
yairsimantov20 Oct 6, 2024
3480b81
threadpool
yairsimantov20 Oct 6, 2024
b3fc8e1
threadpool
yairsimantov20 Oct 8, 2024
6904768
threadpool
yairsimantov20 Oct 8, 2024
df12676
raw
yairsimantov20 Oct 10, 2024
c5ec0c6
with jq
yairsimantov20 Oct 10, 2024
de83870
upserts no entities save
yairsimantov20 Oct 10, 2024
a575911
jira raw
yairsimantov20 Oct 10, 2024
6083790
jira raw
yairsimantov20 Oct 10, 2024
604e99f
jira with jq
yairsimantov20 Oct 10, 2024
91e1777
upserts no entities save
yairsimantov20 Oct 10, 2024
da1e9fd
process pool executor
yairsimantov20 Oct 10, 2024
4ff26de
process pool executor
yairsimantov20 Oct 10, 2024
09d536f
ocean07
yairsimantov20 Oct 12, 2024
d14b49d
ocean07
yairsimantov20 Oct 12, 2024
2eb2b54
ocean08
yairsimantov20 Oct 12, 2024
ab37df1
ocean09
yairsimantov20 Oct 12, 2024
d96ab6a
ocean10
yairsimantov20 Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/_infra/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

LABEL INTEGRATION_VERSION=${INTEGRATION_VERSION}
# Used to ensure that new integrations will be public, see https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility
LABEL org.opencontainers.image.source https://github.com/port-labs/ocean

Check warning on line 8 in integrations/_infra/Dockerfile

View workflow job for this annotation

GitHub Actions / release-integration (integrations/jira/.port/spec.yaml)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "LABEL key=value" should be used instead of legacy "LABEL key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

ENV LIBRDKAFKA_VERSION 1.9.2

Check warning on line 10 in integrations/_infra/Dockerfile

View workflow job for this annotation

GitHub Actions / release-integration (integrations/jira/.port/spec.yaml)

Legacy key/value format with whitespace separator should not be used

LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format More info: https://docs.docker.com/go/dockerfile/rule/legacy-key-value-format/

WORKDIR /app

RUN apt update && \
apt install -y wget make g++ libssl-dev autoconf automake libtool curl librdkafka-dev && \
apt install -y wget make g++ libssl-dev autoconf automake libtool curl librdkafka-dev google-perftools libjemalloc-dev && \
apt-get clean

COPY ./integrations/_infra/init.sh /app/init.sh
Expand All @@ -25,4 +25,4 @@

RUN export POETRY_VIRTUALENVS_CREATE=false && make install/prod && pip cache purge

ENTRYPOINT ./init.sh

Check warning on line 28 in integrations/_infra/Dockerfile

View workflow job for this annotation

GitHub Actions / release-integration (integrations/jira/.port/spec.yaml)

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for ENTRYPOINT to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
3 changes: 2 additions & 1 deletion integrations/_infra/init.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if test -e /usr/local/share/ca-certificates/cert.crt; then
update-ca-certificates
fi
ocean sail

python ./debug.py
412 changes: 206 additions & 206 deletions integrations/jira/poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions integrations/jira/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[tool.poetry]
name = "jira"
version = "0.1.90"
version = "0.1.89-dev017"
description = "Integration to bring information from Jira into Port"
authors = ["Mor Paz <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.11"
port_ocean = {version = "^0.12.1", extras = ["cli"]}
port_ocean = {version = "0.12.2-dev10", extras = ["cli"]}
httpx = "^0.27.0"

[tool.poetry.group.dev.dependencies]
Expand Down
13 changes: 11 additions & 2 deletions port_ocean/core/event_listener/base.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import asyncio
from abc import abstractmethod
from concurrent.futures import ProcessPoolExecutor
from typing import TypedDict, Callable, Any, Awaitable

from pydantic import Extra

from port_ocean.config.base import BaseOceanModel
from port_ocean.utils.signal import signal_handler
from port_ocean.context.ocean import ocean
from port_ocean.utils.misc import IntegrationStateStatus
from port_ocean.utils.signal import signal_handler


class EventListenerEvents(TypedDict):
Expand Down Expand Up @@ -67,7 +69,14 @@ async def _resync(
"""
await self._before_resync()
try:
await self.events["on_resync"](resync_args)
loop = asyncio.get_event_loop()
with ProcessPoolExecutor() as executor:
e = executor.submit(
lambda: asyncio.run_coroutine_threadsafe(
self.events["on_resync"](resync_args), loop
)
)
signal_handler.register(e.cancel)
await self._after_resync()
except Exception as e:
await self._on_resync_failure(e)
Expand Down
4 changes: 2 additions & 2 deletions port_ocean/core/integrations/mixins/sync_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ async def _register_resource_raw(
objects_diff = await self._calculate_raw(
[(resource, results)], parse_all, send_raw_data_examples_amount
)
modified_objects = await self.entities_state_applier.upsert(
await self.entities_state_applier.upsert(
objects_diff[0].entity_selector_diff.passed, user_agent_type
)
return CalculationResult(
objects_diff[0].entity_selector_diff._replace(passed=modified_objects),
objects_diff[0].entity_selector_diff._replace(passed=objects_diff[0].entity_selector_diff.passed),
errors=objects_diff[0].errors,
)

Expand Down
15 changes: 8 additions & 7 deletions port_ocean/log/handlers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import logging
import sys
import threading
import time
from concurrent.futures import ProcessPoolExecutor
from datetime import datetime
from logging.handlers import MemoryHandler
from typing import Any
Expand Down Expand Up @@ -65,18 +65,19 @@ def flush(self) -> None:
if self.ocean is None or not self.buffer:
return

def _wrap_event_loop(_ocean: Ocean, logs_to_send: list[dict[str, Any]]) -> None:
loop = asyncio.new_event_loop()
loop.run_until_complete(self.send_logs(_ocean, logs_to_send))
loop.close()

self.acquire()
logs = list(self._serialized_buffer)
if logs:
self.buffer.clear()
self._serialized_buffer.clear()
self.last_flush_time = time.time()
threading.Thread(target=_wrap_event_loop, args=(self.ocean, logs)).start()
loop = asyncio.new_event_loop()
with ProcessPoolExecutor() as executor:
executor.submit(
lambda: asyncio.run_coroutine_threadsafe(
self.send_logs(self.ocean, logs), loop
)
)
self.release()

async def send_logs(
Expand Down
23 changes: 12 additions & 11 deletions port_ocean/ocean.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import sys
import threading
from concurrent.futures import ProcessPoolExecutor
from contextlib import asynccontextmanager
from typing import Callable, Any, Dict, AsyncIterator, Type

Expand All @@ -9,8 +9,6 @@
from pydantic import BaseModel
from starlette.types import Scope, Receive, Send

from port_ocean.core.handlers.resync_state_updater import ResyncStateUpdater
from port_ocean.core.models import Runtime
from port_ocean.clients.port.client import PortClient
from port_ocean.config.settings import (
IntegrationConfiguration,
Expand All @@ -20,13 +18,15 @@
ocean,
initialize_port_ocean_context,
)
from port_ocean.core.handlers.resync_state_updater import ResyncStateUpdater
from port_ocean.core.integrations.base import BaseIntegration
from port_ocean.core.models import Runtime
from port_ocean.log.sensetive import sensitive_log_filter
from port_ocean.middlewares import request_handler
from port_ocean.utils.misc import IntegrationStateStatus
from port_ocean.utils.repeat import repeat_every
from port_ocean.utils.signal import signal_handler
from port_ocean.version import __integration_version__
from port_ocean.utils.misc import IntegrationStateStatus


class Ocean:
Expand Down Expand Up @@ -92,6 +92,13 @@ async def execute_resync_all() -> None:
)
raise e

def pool_executor_wrapper(event_loop) -> None:
with ProcessPoolExecutor() as executor:
e = executor.submit(lambda: asyncio.run_coroutine_threadsafe(
execute_resync_all(), event_loop
))
signal_handler.register(e.cancel)

interval = self.config.scheduled_resync_interval
loop = asyncio.get_event_loop()
if interval is not None:
Expand All @@ -103,13 +110,7 @@ async def execute_resync_all() -> None:
seconds=interval * 60,
# Not running the resync immediately because the event listener should run resync on startup
wait_first=True,
)(
lambda: threading.Thread(
target=lambda: asyncio.run_coroutine_threadsafe(
execute_resync_all(), loop
)
).start()
)
)(lambda _: pool_executor_wrapper(loop))
await repeated_function()

async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "port-ocean"
version = "0.12.1"
version = "0.12.2-dev06"
description = "Port Ocean is a CLI tool for managing your Port projects."
readme = "README.md"
homepage = "https://app.getport.io"
Expand Down