Skip to content

Instantly share code, notes, and snippets.

from typing import Union
from types import FunctionType, CoroutineType
from inspect import isfunction, ismethod, iscoroutine, isclass, getsourcefile, getsourcelines, getfile
def get_source_location(obj: Union[FunctionType, CoroutineType, type, object]) -> str:
"""
Returns a string with the file and line number where the given function, coroutine, class, or class instance is defined
in a format that many editors recognize to allow Ctrl-click navigation.
class Run(BaseRunV2):
"""Run schema for the V2 API in the Tracer."""
execution_order: int
child_execution_order: int
child_runs: List[Run] = Field(default_factory=list)
tags: Optional[List[str]] = Field(default_factory=list)
events: List[Dict[str, Any]] = Field(default_factory=list)
trace_id: Optional[UUID] = None
dotted_order: Optional[str] = None
2024-02-21T12:44:27.573493Z INFO kooha::application: Kooha (io.github.seadve.Kooha)
2024-02-21T12:44:27.573511Z INFO kooha::application: Version: 2.2.4 ()
2024-02-21T12:44:27.573514Z INFO kooha::application: Datadir: /usr/share/kooha
2024-02-21T12:44:30.512983Z ERROR kooha::window: Failed to start recording
Caused by:
0: Check out <a href="https://github.com/SeaDve/Kooha#-it-doesnt-work">It Doesn't Work page</a> for help.
1: Failed to create ScreencastSession
2: Failed to create session
3: Failed to call `CreateSession` with parameters: Variant { ptr: 0x64bb29fabbc0, type: VariantTy { inner: "(a{sv})" }, value: "({'handle_token': <'kooha_1'>, 'session_handle_token': <'kooha_0'>},)" }
[D-BUS Service]
Name=org.freedesktop.portal.Desktop
Exec=/usr/lib/xdg-desktop-portal
SystemdService=xdg-desktop-portal.service
AssumedAppArmorLabel=unconfined
[D-BUS Service]
Name=org.freedesktop.portal.Desktop
Exec=/usr/lib/xdg-desktop-portal
SystemdService=xdg-desktop-portal.service
AssumedAppArmorLabel=unconfined
int32 0
method call time=1708518640.367155 sender=:1.11029 -> destination=ca.desrt.dconf serial=33 path=/ca/desrt/dconf/Writer/user; interface=ca.desrt.dconf.Writer; member=Change
array of bytes [
2f 69 6f 2f 67 69 74 68 75 62 2f 73 65 61 64 76 65 2f 4b 6f 6f 68 61 2f
73 63 72 65 65 6e 63 61 73 74 2d 72 65 73 74 6f 72 65 2d 74 6f 6b 65 6e
00 00 00 00 00 00 00 00 00 00 73 00 31 3d
]
method return time=1708518640.367463 sender=:1.25 -> destination=:1.11029 serial=54 reply_serial=33
string ":1.25:user:39"
method call time=1708518640.367859 sender=:1.11029 -> destination=org.freedesktop.DBus serial=34 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
HOME=/home/ldorigo
LANG=en_US.UTF-8
LOGNAME=ldorigo
MAIL=/var/spool/mail/ldorigo
PATH=/usr/local/bin:/usr/bin
SHELL=/bin/zsh
USER=ldorigo
XDG_DATA_DIRS=/home/ldorigo/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/
XDG_RUNTIME_DIR=/run/user/1000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
729 method call time=1707814777.024023 sender=:1.127 -> destination=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
* 730 method return time=1707814777.024079 sender=org.freedesktop.DBus -> destination=:1.127 serial=4294967295 reply_serial=1
* 731 string ":1.127"
732 signal time=1707814777.024101 sender=org.freedesktop.DBus -> destination=(null destination) serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
* 733 string ":1.127"
734 string ""
* 735 string ":1.127"
* 736 signal time=1707814777.024133 sender=org.freedesktop.DBus -> destination=:1.127 serial=4294967295 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
* 737 string ":1.127"
* 738 method call time=1707814777.024177 sender=:1.127 -> destination=org.freedesktop.DBus serial=2 path=/org/freedesktop/DBus; interface=org.freede
print(f"{datetime.datetime.now()} - RetrieveWithSimilarity")
# Retrieve query
if not previous_output.search_query:
previous_output.search_query = Query(request.query)
query = previous_output.search_query
self._debug_log(f"Search query: {query.query}")
print(f"{datetime.datetime.now()} - going to embed query")
# Embed query
# embedding = self.vectorstore._embed_query(query)
import asyncio
async def loading():
while True:
for i in range(20):
print(".", end="")
await asyncio.sleep(0.3)
# Clear the line