canvas 0.1.10__py3-none-any.whl → 0.1.12__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 canvas might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: canvas
3
- Version: 0.1.10
3
+ Version: 0.1.12
4
4
  Summary: SDK to customize event-driven actions in your Canvas instance
5
5
  License: MIT
6
6
  Author: Canvas Team
@@ -9,7 +9,7 @@ canvas_cli/apps/plugin/__init__.py,sha256=72Gcu2T9GsRLPbBApS9V0ZKSzehEE3hqgU_pie
9
9
  canvas_cli/apps/plugin/plugin.py,sha256=03Xq7Xhvu6GszGPtIDWB3iMr1i_AZ9UPc6est2qoUK4,9362
10
10
  canvas_cli/apps/plugin/tests.py,sha256=_8fHTGlQermt4AVs20nsTYcs2bDRNEqr9CGE29pD6YQ,1035
11
11
  canvas_cli/conftest.py,sha256=pGvVS6VT0Zll_Lp3ezLh2jykOk-2HTBVH8RP5FwLUVw,930
12
- canvas_cli/main.py,sha256=SWh8E6gY-L5xygQ7cJf2seH9xT_x6Se4bRjB7WLFWCk,2181
12
+ canvas_cli/main.py,sha256=RbGZtIBmm81GUkN_80u_VB-CL7kxwID_GoDbkSgo7LQ,3607
13
13
  canvas_cli/templates/plugins/default/cookiecutter.json,sha256=dWEB3wJ8U4bko8jX26PgLLg_jgWlafLTNqsGnY1PUcg,124
14
14
  canvas_cli/templates/plugins/default/{{ cookiecutter.__project_slug }}/CANVAS_MANIFEST.json,sha256=9N0u5hN0GqjPvUh_B3YHtvyntEvxUGbInbQeprU0TS0,787
15
15
  canvas_cli/templates/plugins/default/{{ cookiecutter.__project_slug }}/README.md,sha256=7QdF2JWlWwq6Us9LzkO9XWJU4IU7Q6RD_w8ImcS-hrI,347
@@ -60,7 +60,7 @@ canvas_sdk/utils/__init__.py,sha256=sFuhqcWvXb2-33FOuXZgWuUeC5jZL2MDoqjGoQZGwd8,
60
60
  canvas_sdk/utils/http.py,sha256=YOgUFp7FOFhbDwkGhCiD3JLZ342oNZR-qncMxv2qSjw,2159
61
61
  canvas_sdk/utils/tests.py,sha256=t3MScbIfzXkQttMIvj0dRzJlFVS8LFU8WgWRrChM-H0,1931
62
62
  canvas_sdk/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
- canvas-0.1.10.dist-info/METADATA,sha256=paSMCQyCQ2-Ua_fo7pI26J3fLITr0wMGrY7ZmSVazb8,3532
64
- canvas-0.1.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
- canvas-0.1.10.dist-info/entry_points.txt,sha256=VSmSo1IZ3aEfL7enmLmlWSraS_IIkoXNVeyXzgRxFiY,46
66
- canvas-0.1.10.dist-info/RECORD,,
63
+ canvas-0.1.12.dist-info/METADATA,sha256=vKcG04sZrNpBolVNTuwv_15r0QV26NFb_S9quv4qzbM,3532
64
+ canvas-0.1.12.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
+ canvas-0.1.12.dist-info/entry_points.txt,sha256=VSmSo1IZ3aEfL7enmLmlWSraS_IIkoXNVeyXzgRxFiY,46
66
+ canvas-0.1.12.dist-info/RECORD,,
canvas_cli/main.py CHANGED
@@ -1,12 +1,18 @@
1
1
  import importlib.metadata
2
+ import json
3
+ import random
2
4
  from pathlib import Path
3
- from typing import Optional
5
+ from typing import Annotated, Optional
4
6
 
7
+ import grpc
5
8
  import typer
6
9
 
7
10
  from canvas_cli.apps import plugin
8
11
  from canvas_cli.apps.logs import logs as logs_command
9
12
  from canvas_cli.utils.context import context
13
+ from generated.messages.events_pb2 import Event as PluginRunnerEvent
14
+ from generated.messages.events_pb2 import EventType as PluginRunnerEventType
15
+ from generated.services.plugin_runner_pb2_grpc import PluginRunnerStub
10
16
 
11
17
  APP_NAME = "canvas_cli"
12
18
 
@@ -51,6 +57,37 @@ def get_or_create_config_file() -> Path:
51
57
  return config_path
52
58
 
53
59
 
60
+ @app.command()
61
+ def emit(
62
+ event_fixture: str,
63
+ plugin_runner_port: Annotated[
64
+ str, typer.Option(help="Port of your locally running plugin runner")
65
+ ] = "50051",
66
+ ) -> None:
67
+ """
68
+ Grab an event from a fixture file and send it your locally running plugin-runner process.
69
+ Any resultant effects will be printed.
70
+
71
+ Valid fixture files are newline-delimited JSON, with each containing the keys `EventType`, `target`, and `context`. Some fixture files are included in the canvas-plugins repo.
72
+ """
73
+ # Grab a random event from the fixture file ndjson
74
+ lines = Path(event_fixture).read_text().splitlines()
75
+ myline = random.choice(lines)
76
+ event_data = json.loads(myline)
77
+ event = PluginRunnerEvent(
78
+ type=PluginRunnerEventType.Value(event_data["EventType"]),
79
+ target=event_data["target"],
80
+ context=event_data["context"],
81
+ )
82
+ with grpc.insecure_channel(f"localhost:{plugin_runner_port}") as channel:
83
+ stub = PluginRunnerStub(channel)
84
+ responses = stub.HandleEvent(event)
85
+
86
+ for response in responses:
87
+ for effect in response.effects:
88
+ print(effect)
89
+
90
+
54
91
  @app.callback()
55
92
  def main(
56
93
  version: Optional[bool] = typer.Option(