lttng-dev Archive mirror
 help / color / mirror / Atom feed
From: "Wu, Yannan via lttng-dev" <lttng-dev@lists.lttng.org>
To: Kienan Stewart <kstewart@efficios.com>,
	"lttng-dev@lists.lttng.org" <lttng-dev@lists.lttng.org>
Subject: Re: [lttng-dev] [babeltrace2]about python self-defined plugin loading
Date: Fri, 26 Apr 2024 13:56:52 +0000	[thread overview]
Message-ID: <8c49688cb4bb43009b5ba1f6fb8e32cf@amazon.com> (raw)
In-Reply-To: <d00cba29-4ebc-4974-890c-ecf821b2fa8a@efficios.com>


[-- Attachment #1.1: Type: text/plain, Size: 4169 bytes --]

Hihi, Kienan,

I finally find a workaround. I could success with the following code:
file_name = "bt_plugin_latency_filter.py"
current_directory=os.getcwd()

file_path = os.path.join(current_directory, file_name)
pset=bt2.find_plugins_in_path(file_path)

forplugininpset:

if plugin.name=="latency_filter"and hasattr(plugin,"filter_component_classes"):

    latency_filter_comp_cls=plugin.filter_component_classes['LatencyFilter']



But loading the whole directory, it just doesnt work from command line.

Amanda















________________________________
From: Kienan Stewart <kstewart@efficios.com>
Sent: Thursday, April 25, 2024 11:43:05 PM
To: Wu, Yannan; lttng-dev@lists.lttng.org
Subject: RE: [EXTERNAL] [lttng-dev] [babeltrace2]about python self-defined plugin loading

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.



My apologies,

there is a typo in my previous e-mail, the library directory should be:

`<libdir>/babeltrace2/plugin-providers/'

thanks,
kienan

On 4/25/24 11:41 AM, Kienan Stewart via lttng-dev wrote:
> Hi Amanda,
>
> could you double-check to ensure that babeltrace2 was built with
> `--enable-python-plugins`, and that `import bt2` works?
>
> There should be a babeltrace2-python-plugin-provider.so in
> `<libdir>/babeltrace2/plugin-provides`
>
> thanks,
> kienan
>
>
> On 4/24/24 11:28 PM, Wu, Yannan via lttng-dev wrote:
>> Hi, There,
>>
>> I am trying to construct a customized filter and sink based on
>> babeltrace2 python binding. However, nether mine plugin nor the
>> plugins sample I could find on the internet all dont work.
>>
>> For example,
>> https://github.com/simark/babeltrace-fun-plugins/tree/master/my-first-components <https://github.com/simark/babeltrace-fun-plugins/tree/master/my-first-components>
>>
>> I just downloaded the py file and run the exact command, it failed.
>> The log is as following:
>>
>>
>> babeltrace2 --plugin-path . -c source.demo.MyFirstSource -c
>> sink.demo.MyFirstSink
>> 04-24 16:52:04.349 919805 919805 E CLI
>> add_descriptor_to_component_descriptor_set@babeltrace2.c:1720 Cannot
>> find component class: plugin-name="demo",
>> comp-cls-name="MyFirstSource", comp-cls-type=1
>> 04-24 16:52:04.349 919805 919805 E CLI
>> cmd_run_ctx_init@babeltrace2.c:1882 Cannot find an operative message
>> interchange protocol version to use to create the `run` command's
>> graph: status=ERROR
>> 04-24 16:52:04.349 919805 919805 E CLI cmd_run@babeltrace2.c:2465
>> Cannot initialize the command's context.
>>
>> ERROR:    [Babeltrace CLI] (babeltrace2.c:2465)
>>    Cannot initialize the command's context.
>> CAUSED BY [Babeltrace CLI] (babeltrace2.c:1882)
>>    Cannot find an operative message interchange protocol version to
>> use to create the `run` command's graph: status=ERROR
>> CAUSED BY [Babeltrace CLI] (babeltrace2.c:1720)
>>    Cannot find component class: plugin-name="demo",
>> comp-cls-name="MyFirstSource", comp-cls-type=1
>>
>> babeltrace2 --version
>> Babeltrace 2.0.7 "Amqui" [v2.0.6-1-g825a0ed6d]
>>
>> Amqui (/ɒmkwiː/) is a town in eastern Québec, Canada, at the base of
>> the Gaspé peninsula in Bas-Saint-Laurent. Located at the
>> confluence of the Humqui and Matapédia Rivers, its proximity to
>> woodlands makes it a great destination for outdoor activities such as
>> camping, hiking, and mountain biking.
>> yannanwu@ue91e96f2951b5c:~/trees/lttng_test_run$
>>
>> Is the cli changed or something? How can I make it right?
>>
>> Besides, is it possible we create a pipeline in python and make use
>> the the python drafted plugin? Can you advise me how?
>>
>> Amanda
>>
>>
>>
>> _______________________________________________
>> lttng-dev mailing list
>> lttng-dev@lists.lttng.org
>> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

[-- Attachment #1.2: Type: text/html, Size: 10024 bytes --]

[-- Attachment #2: Type: text/plain, Size: 156 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

  reply	other threads:[~2024-04-26 13:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25  3:28 [lttng-dev] [babeltrace2]about python self-defined plugin loading Wu, Yannan via lttng-dev
2024-04-25 15:41 ` Kienan Stewart via lttng-dev
2024-04-25 15:43   ` Kienan Stewart via lttng-dev
2024-04-26 13:56     ` Wu, Yannan via lttng-dev [this message]
2024-04-26 14:57       ` Simon Marchi via lttng-dev
2024-04-26 15:33         ` Wu, Yannan via lttng-dev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8c49688cb4bb43009b5ba1f6fb8e32cf@amazon.com \
    --to=lttng-dev@lists.lttng.org \
    --cc=kstewart@efficios.com \
    --cc=yannanwu@amazon.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).