jararaca 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of jararaca might be problematic. Click here for more details.
- jararaca/cli.py +56 -25
- jararaca/messagebus/interceptors/aiopika_publisher_interceptor.py +5 -4
- {jararaca-0.3.0.dist-info → jararaca-0.3.1.dist-info}/METADATA +1 -1
- {jararaca-0.3.0.dist-info → jararaca-0.3.1.dist-info}/RECORD +7 -7
- {jararaca-0.3.0.dist-info → jararaca-0.3.1.dist-info}/LICENSE +0 -0
- {jararaca-0.3.0.dist-info → jararaca-0.3.1.dist-info}/WHEEL +0 -0
- {jararaca-0.3.0.dist-info → jararaca-0.3.1.dist-info}/entry_points.txt +0 -0
jararaca/cli.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import importlib
|
|
2
2
|
import importlib.resources
|
|
3
|
+
import multiprocessing
|
|
3
4
|
import os
|
|
4
5
|
import sys
|
|
5
6
|
import time
|
|
6
7
|
from codecs import StreamWriter
|
|
8
|
+
from pathlib import Path
|
|
7
9
|
from typing import Any
|
|
8
10
|
from urllib.parse import urlparse, urlunsplit
|
|
9
11
|
|
|
@@ -265,6 +267,30 @@ def scheduler_v2(
|
|
|
265
267
|
scheduler.run()
|
|
266
268
|
|
|
267
269
|
|
|
270
|
+
def generate_interfaces(app_path: str, file_path: str) -> None:
|
|
271
|
+
try:
|
|
272
|
+
app = find_microservice_by_module_path(app_path)
|
|
273
|
+
content = write_microservice_to_typescript_interface(app)
|
|
274
|
+
|
|
275
|
+
with open(file_path, "w", encoding="utf-8") as file:
|
|
276
|
+
# Save current position
|
|
277
|
+
file.tell()
|
|
278
|
+
|
|
279
|
+
# Reset file to beginning
|
|
280
|
+
file.seek(0)
|
|
281
|
+
file.truncate()
|
|
282
|
+
|
|
283
|
+
# Write new content
|
|
284
|
+
file.write(content)
|
|
285
|
+
file.flush()
|
|
286
|
+
|
|
287
|
+
print(
|
|
288
|
+
f"Generated TypeScript interfaces at {time.strftime('%H:%M:%S')} at {str(Path(file_path).absolute())}"
|
|
289
|
+
)
|
|
290
|
+
except Exception as e:
|
|
291
|
+
print(f"Error generating TypeScript interfaces: {e}", file=sys.stderr)
|
|
292
|
+
|
|
293
|
+
|
|
268
294
|
@cli.command()
|
|
269
295
|
@click.argument(
|
|
270
296
|
"app_path",
|
|
@@ -272,7 +298,7 @@ def scheduler_v2(
|
|
|
272
298
|
)
|
|
273
299
|
@click.argument(
|
|
274
300
|
"file_path",
|
|
275
|
-
type=click.
|
|
301
|
+
type=click.Path(file_okay=True, dir_okay=False),
|
|
276
302
|
)
|
|
277
303
|
@click.option(
|
|
278
304
|
"--watch",
|
|
@@ -283,32 +309,11 @@ def scheduler_v2(
|
|
|
283
309
|
type=click.Path(exists=True, file_okay=False, dir_okay=True),
|
|
284
310
|
default="src",
|
|
285
311
|
)
|
|
286
|
-
def gen_tsi(app_path: str, file_path:
|
|
312
|
+
def gen_tsi(app_path: str, file_path: str, watch: bool, src_dir: str) -> None:
|
|
287
313
|
"""Generate TypeScript interfaces from a Python microservice."""
|
|
288
314
|
|
|
289
|
-
# Generate typescript interfaces
|
|
290
|
-
def generate_interfaces() -> None:
|
|
291
|
-
try:
|
|
292
|
-
app = find_microservice_by_module_path(app_path)
|
|
293
|
-
content = write_microservice_to_typescript_interface(app)
|
|
294
|
-
|
|
295
|
-
# Save current position
|
|
296
|
-
file_path.tell()
|
|
297
|
-
|
|
298
|
-
# Reset file to beginning
|
|
299
|
-
file_path.seek(0)
|
|
300
|
-
file_path.truncate()
|
|
301
|
-
|
|
302
|
-
# Write new content
|
|
303
|
-
file_path.write(content)
|
|
304
|
-
file_path.flush()
|
|
305
|
-
|
|
306
|
-
print(f"Generated TypeScript interfaces at {time.strftime('%H:%M:%S')}")
|
|
307
|
-
except Exception as e:
|
|
308
|
-
print(f"Error generating TypeScript interfaces: {e}", file=sys.stderr)
|
|
309
|
-
|
|
310
315
|
# Initial generation
|
|
311
|
-
generate_interfaces()
|
|
316
|
+
generate_interfaces(app_path, file_path)
|
|
312
317
|
|
|
313
318
|
# If watch mode is not enabled, exit
|
|
314
319
|
if not watch:
|
|
@@ -334,7 +339,33 @@ def gen_tsi(app_path: str, file_path: StreamWriter, watch: bool, src_dir: str) -
|
|
|
334
339
|
)
|
|
335
340
|
if not event.is_directory and src_path.endswith(".py"):
|
|
336
341
|
print(f"File changed: {src_path}")
|
|
337
|
-
|
|
342
|
+
# Create a completely detached process to ensure classes are reloaded
|
|
343
|
+
process = multiprocessing.get_context("spawn").Process(
|
|
344
|
+
target=generate_interfaces,
|
|
345
|
+
args=(app_path, file_path),
|
|
346
|
+
daemon=False, # Non-daemon to ensure it completes
|
|
347
|
+
)
|
|
348
|
+
process.start()
|
|
349
|
+
# Don't join to keep it detached from main process
|
|
350
|
+
|
|
351
|
+
def _run_generator_in_separate_process(
|
|
352
|
+
self, app_path: str, file_path: str
|
|
353
|
+
) -> None:
|
|
354
|
+
# Using Python executable to start a completely new process
|
|
355
|
+
# This ensures all modules are freshly imported
|
|
356
|
+
generate_interfaces(app_path, file_path)
|
|
357
|
+
# cmd = [
|
|
358
|
+
# sys.executable,
|
|
359
|
+
# "-c",
|
|
360
|
+
# (
|
|
361
|
+
# f"import sys; sys.path.extend({sys.path}); "
|
|
362
|
+
# f"from jararaca.cli import generate_interfaces; "
|
|
363
|
+
# f"generate_interfaces('{app_path}', '{file_path}')"
|
|
364
|
+
# ),
|
|
365
|
+
# ]
|
|
366
|
+
# import subprocess
|
|
367
|
+
|
|
368
|
+
# subprocess.run(cmd, check=False)
|
|
338
369
|
|
|
339
370
|
# Set up observer
|
|
340
371
|
observer = Observer()
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
from contextlib import asynccontextmanager
|
|
2
3
|
from datetime import datetime, timedelta
|
|
3
4
|
from datetime import tzinfo as _TzInfo
|
|
@@ -29,10 +30,10 @@ class AIOPikaMessagePublisher(MessagePublisher):
|
|
|
29
30
|
self.message_broker_backend = message_broker_backend
|
|
30
31
|
|
|
31
32
|
async def publish(self, message: IMessage, topic: str) -> None:
|
|
32
|
-
exchange = await self.channel.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
exchange = await self.channel.get_exchange(self.exchange_name, ensure=False)
|
|
34
|
+
if not exchange:
|
|
35
|
+
logging.warning(f"Exchange {self.exchange_name} not found")
|
|
36
|
+
return
|
|
36
37
|
routing_key = f"{topic}."
|
|
37
38
|
await exchange.publish(
|
|
38
39
|
aio_pika.Message(body=message.model_dump_json().encode()),
|
|
@@ -3,7 +3,7 @@ jararaca/__main__.py,sha256=-O3vsB5lHdqNFjUtoELDF81IYFtR-DSiiFMzRaiSsv4,67
|
|
|
3
3
|
jararaca/broker_backend/__init__.py,sha256=GzEIuHR1xzgCJD4FE3harNjoaYzxHMHoEL0_clUaC-k,3528
|
|
4
4
|
jararaca/broker_backend/mapper.py,sha256=vTsi7sWpNvlga1PWPFg0rCJ5joJ0cdzykkIc2Tuvenc,696
|
|
5
5
|
jararaca/broker_backend/redis_broker_backend.py,sha256=a7DHchy3NAiD71Ix8SwmQOUnniu7uup-Woa4ON_4J7I,5786
|
|
6
|
-
jararaca/cli.py,sha256=
|
|
6
|
+
jararaca/cli.py,sha256=oaLqJlb-GAbhYpQHzl-P8ajPdo-G_ddIuSu2SsZNDh8,10244
|
|
7
7
|
jararaca/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
jararaca/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
jararaca/core/providers.py,sha256=wktH84FK7c1s2wNq-fudf1uMfi3CQBR0neU2czJ_L0U,434
|
|
@@ -16,7 +16,7 @@ jararaca/messagebus/bus_message_controller.py,sha256=Xd_qwnX5jUvgBTCarHR36fvtol9
|
|
|
16
16
|
jararaca/messagebus/consumers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
jararaca/messagebus/decorators.py,sha256=y-w4dWbP9ZW3ZJ4mE9iIaxw01ZC5snEbOuBY5NC-Bn0,5626
|
|
18
18
|
jararaca/messagebus/interceptors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
jararaca/messagebus/interceptors/aiopika_publisher_interceptor.py,sha256=
|
|
19
|
+
jararaca/messagebus/interceptors/aiopika_publisher_interceptor.py,sha256=Aex87wopB34sMNzXBgi4KucVHjL2wYog3-IH75DAfDk,5387
|
|
20
20
|
jararaca/messagebus/interceptors/publisher_interceptor.py,sha256=fQFFW9hH6ZU3UOyR7kMPrNp9wA71qEy5XlgrBQdBMS4,1230
|
|
21
21
|
jararaca/messagebus/message.py,sha256=U6cyd2XknX8mtm0333slz5fanky2PFLWCmokAO56vvU,819
|
|
22
22
|
jararaca/messagebus/publisher.py,sha256=K7WsOMVTyLmdms3ZKEshqrQc_DhNreiFK-HnmOT9Ce0,1965
|
|
@@ -66,8 +66,8 @@ jararaca/tools/metadata.py,sha256=7nlCDYgItNybentPSSCc2MLqN7IpBd0VyQzfjfQycVI,14
|
|
|
66
66
|
jararaca/tools/typescript/interface_parser.py,sha256=4SHt094P-QawMFHSyMCiujQf8Niw7xACIO1RHBM8-w4,29192
|
|
67
67
|
jararaca/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
68
68
|
jararaca/utils/rabbitmq_utils.py,sha256=zFqZE-j6TSWFOEPbkIaB2hy2sqsXup-5421jIiPLfXY,2543
|
|
69
|
-
jararaca-0.3.
|
|
70
|
-
jararaca-0.3.
|
|
71
|
-
jararaca-0.3.
|
|
72
|
-
jararaca-0.3.
|
|
73
|
-
jararaca-0.3.
|
|
69
|
+
jararaca-0.3.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
70
|
+
jararaca-0.3.1.dist-info/METADATA,sha256=TRaKZQ_5vbE3OS_sTSYCpq7aYkDX19zFlebpkenHo9A,4951
|
|
71
|
+
jararaca-0.3.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
72
|
+
jararaca-0.3.1.dist-info/entry_points.txt,sha256=WIh3aIvz8LwUJZIDfs4EeH3VoFyCGEk7cWJurW38q0I,45
|
|
73
|
+
jararaca-0.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|