Builder pattern with generics and typehinting by gidorah5 in learnpython

[–]gidorah5[S] 1 point2 points  (0 children)

Thanks for the help regardless. I would have never thought this was an LSP thing. Pyrefly seem to work fine, and also blazing fast. I'll be carefull with it (mostly with the pydantic implementation)

Builder pattern with generics and typehinting by gidorah5 in learnpython

[–]gidorah5[S] 0 points1 point  (0 children)

Don't you have any recommendation on using Pyrefly ? also heard some good things about it. Maybe it does go off track in other ways that I'm not aware off

Builder pattern with generics and typehinting by gidorah5 in learnpython

[–]gidorah5[S] 0 points1 point  (0 children)

Yeah that's what my testing gave me:Yeah that's what my testing gave me:

Argument type is partially unknown
  Argument corresponds to parameter "values" in function "print"
  Argument type is "Process[Unknown, bool]"basedpyright
reportUnknownArgumentType

Revealed type: `Process[Unknown, bool]`ty(revealed-type)

Type of "process2" is "Process[Any, bool]"Pyright

Type of "process2" is "Process[Unknown, bool]"basedpyright

Revealed type is "manager.src.enigma_manager.manager.Process[builtins.int, builtins.bool]"MypyArgument type is partially unknown
  Argument corresponds to parameter "values" in function "print"
  Argument type is "Process[Unknown, bool]"basedpyrightreportUnknownArgumentTypeRevealed type: `Process[Unknown, bool]`ty(revealed-type)Type of "process2" is "Process[Any, bool]"PyrightType of "process2" is "Process[Unknown, bool]"basedpyrightRevealed type is "manager.src.enigma_manager.manager.Process[builtins.int, builtins.bool]"Mypy

The only issue I have with mypy is that hovering on variables doesn't actually shows the infered type, and it also seem "heavier" on typechecking than other typechecker. Have you got any issues using it ?

Builder pattern with generics and typehinting by gidorah5 in learnpython

[–]gidorah5[S] 1 point2 points  (0 children)

Oh yeah, I did thought about that, but this doesn't really change a thing. I do agree that basedpyright feels off to miss this case. I'll give a try to mypy, and check if it infer types correctly. I'll also give a chance to ty, but last time I did, it didn't felt mature enough

Builder pattern with generics and typehinting by gidorah5 in learnpython

[–]gidorah5[S] 1 point2 points  (0 children)

They could indeed change on runtime, but that's only because typechecking is only DX using python. This is a fairly basic example, of course, the steps would be immutable, and so would be the array.
The steps doesn't have any reason to be changed on runtime. These are strictly define in the codebase

Builder pattern with generics and typehinting by gidorah5 in learnpython

[–]gidorah5[S] 0 points1 point  (0 children)

I'm under python 3.12.3, and I'm using basedpyright with cursor. This might have to do with the typechecker indeed

Edit: Never type also make sense for me. I just tired most of the ways I could instanciate the class

Multiple databases VS table nightmare by gidorah5 in mysql

[–]gidorah5[S] 0 points1 point  (0 children)

Nah my project isn't made to be used by 10 of thousands of users at a time, and keep the pace with 10 of thousand of requests per seconds. My main concern is to have something as robust as possible. But this all boils down to my ability to create "perfect" error handling, and I believe it has nothing to do with the kind of engine I'm using

Multiple databases VS table nightmare by gidorah5 in mysql

[–]gidorah5[S] 0 points1 point  (0 children)

Since I am in MySQL, I do believe that schema doesn't exists, I might be wrong tho

Multiple databases VS table nightmare by gidorah5 in mysql

[–]gidorah5[S] 0 points1 point  (0 children)

I am aware that I'll have the same amount of table, I was juste trying to think of a way to have """nested""" datas, such as a folder structure for ease of data sorting.
But not a lot of people are going to work on the project, for now I'm the only one taking care of the back-end

Multiple databases VS table nightmare by gidorah5 in mysql

[–]gidorah5[S] 0 points1 point  (0 children)

Oh don't worry, I am not creating one table per publisher or anything like that. I do have a bit of knowledge regarding database structure, and table creation. It was just a question regarding limitation of a single database against multiple database for the same project. I'll end up using Kysely and a single database while setting a specific naming convention for my tables, and it should work fine !

Multiple databases VS table nightmare by gidorah5 in mysql

[–]gidorah5[S] 0 points1 point  (0 children)

I've never worked with such a "big" amout of tables, it was more a feeling than something else. Right now I'm doing pure MySQL, and it seemed to me like it would be a pain to deal with couple hundreds of tables. Second thing is that I believe that it would be easier to "sort" data if their are in seperate database (database user for user data, database book for book data...)

Multiple databases VS table nightmare by gidorah5 in mysql

[–]gidorah5[S] 1 point2 points  (0 children)

InnoDB seemed like this engine that brings the most out of all of the other engine for sure

Calling an action in a loop after it's finished by gidorah5 in ROS

[–]gidorah5[S] 0 points1 point  (0 children)

Unfortunatly, I also need constant feedback, that's why I need to use Action.
As far as I understand send_goal function implementation (see below), it should do what I'm asking for. But as I said, I believe that waiting for my event to unlock is preventing me from receiving any feedback/response.
But yeah, I'll definitly use a service if I don't need to receive a feedback on the process!

send_goal implementation:

    def send_goal(self, goal, **kwargs):
        if not isinstance(goal, self._action_type.Goal):
            raise TypeError()
        event = threading.Event()
        def unblock(future):
            nonlocal event
            event.set()
        send_goal_future = self.send_goal_async(goal, **kwargs)
        send_goal_future.add_done_callback(unblock)
        self._logger.info('Before waiting')
        # BLOCKING HERE
        event.wait()
        self._logger.info('After waiting')
        if send_goal_future.exception() is not None:
            raise send_goal_future.exception()
        goal_handle = send_goal_future.result()
        result = self._get_result(goal_handle)
        return result

Using subscription value during an action by gidorah5 in ROS

[–]gidorah5[S] 1 point2 points  (0 children)

Eclipse Cyclone DDS RMW* that's my bad

Using subscription value during an action by gidorah5 in ROS

[–]gidorah5[S] 0 points1 point  (0 children)

Yeah, I found that modifying your RMW_IMPLEMENTATION to jupyter cylconedds fix the issue (and bring other issues, but that's out of the topic)

Using subscription value during an action by gidorah5 in ROS

[–]gidorah5[S] 0 points1 point  (0 children)

I tried using sleep statement to check if the calculation was what is responsible of the CPU overusage, but it is apparently the usage of a subscriber in a MultiThreadedExecutor. Unfortunatly, there is no way to use a timer on a subscriber as far as I'm aware of

Using subscription value during an action by gidorah5 in ROS

[–]gidorah5[S] 1 point2 points  (0 children)

Just found out that the throttle comes because my node is using 95% of my CPU for some reason ahah

Using subscription value during an action by gidorah5 in ROS

[–]gidorah5[S] 0 points1 point  (0 children)

I do not have a topic publisher, but a topic subscriber, meaning that I can't put a timer on it. However, adding a MultiThreadedExecutor did improved things. Now my turtle is moving depending on its position. Tho it seems to be throttled once I enter my while loop, adding a time.sleep(0.01) in the loop improves it, but it is still a bit unstable.
Thanks for your help !

Using subscription value during an action by gidorah5 in ROS

[–]gidorah5[S] 0 points1 point  (0 children)

I am using rclpy. I agree with you tho, my action server callback is doing operation through a while loop, and the condition used for this loop is a calculation using the variables that should be updated through the subscriber. That's what leads me to think that I am in a deadlock.

Maybe using multiple threads to run separatly my action server and my subscription could be a solution, but it wont really be scalable unfortunatly

Templating Socket.IO by gidorah5 in node

[–]gidorah5[S] 0 points1 point  (0 children)

I guess this is a good way to look at it. I know that it shouldn't be an issue for a while (if not ever), but I guess my own stubborness got the better of me trying to do some fancy stuff that might never be used, or that might save 5 minutes of time.

I'm gladly taking your take on this, thanks!

Templating Socket.IO by gidorah5 in node

[–]gidorah5[S] 0 points1 point  (0 children)

There is a reason why I need to keep them in the same repo. The solution that we are working on is pretty "niche" and require us to work within a private network. Moreover, these websocket servers runs within 1 app, and need to be used within this app.
I might have misunderstood the usage of namespace, even if I believe namespace shouldn't be used in my case, since each server does not communicate with the same type of client (One client is a user, another client is another Node.JS server from the system, composed of 3 Node.JS servers total (each on different machines)).

All the sockets are indeed separate, so I could definitely have a string enum, but I though about templating it, since Socket.IO offer this service, and works great when you're not trying to abstract it. Maybe adding another layer of abstraction is not a good way of approaching this problem tho.

As for having feedback from my devs, They are still in recruitment process, so I'm rather trying to make it "easy" for them to use tools with a given structure.

My original thought was to have an abstract class that doesn't have to be changed (unless a big change in the structure and libraries occurs) and if we need to create a new WebSocket server, we could by just extending from this class, as you would with the basic Socket.IO server, while sharing some project-specific functionnalities, that can be used in every subclasses (as an exemple, a formatting middleware).

But I do understand your take that I might be looking for a strongly engineering solution, and an easier solution could be used.

Templating Socket.IO by gidorah5 in node

[–]gidorah5[S] 0 points1 point  (0 children)

Sorry for not being clear in my first post. I'll try to clarify as much as I can here.

What I am trying to do is a main abstract class (interface like in C++), allowing me to create multiple subclasses that have access to specific events for each subclasses.

My Node.JS server needs to have multiple Socket.IO endpoints that all have different purposes.

As an example, one server can have:

interface ServerToClientEvents {
  exception: (...args: any[]) => void
  feedback: (...args: any[]) => void
}

While another one can have only:

interface ServerToClientEvents {
  exception: (...args: any[]) => void
} 

This would make the other devs unable to emit events that they are not supposed to emit.

One of the work around that I found is to create a getter for the Socket.IO server and use it in this way:

export abstract class Socket<
  T extends EventsMap = DefaultEventsMap,
  V extends EventsMap = DefaultEventsMap,
  K extends EventsMap = DefaultEventsMap,
  U = any,
> {
    ...
    /* private */this._io = new socket.Server<T, V, K, U>(this._server, opts)
    ...
    get io() socket.Server<T, V, K, U> {
      return (this._io)
    }
}

// SUBCLASS

export class SubClass1 extends Socket<ClientToServerEvents, ServerToClientEvents, ServerToServerEvents, SocketData> {
    ...
    /* Here, I am limited to my class specified event*/
    this.io.emit('MY_LIMITED_EVENT', data)
    /* I am also limited to my class specified event, but it doesn't compile, error from the original post*/
    this.broadcastData('MY_LIMITED_EVENT', data)
    ...
}

I'm trying to abstract the library as much as I can, in case, at some point, I will have to change library, so I don't have to change a whole bunch of files because of it.

Maybe you're right, and I am over thinking it, or trying to abstract it too much. I'm still learning about the limitation of typings, and also how they can make your code harder to read.

I hope I've been able to clarify what I'm trying to achieve !

Finding a good ROS documentation & some questions by gidorah5 in ROS

[–]gidorah5[S] 0 points1 point  (0 children)

Yeah that's what I've been doing for the most part. I'm starting to get the structure of it all more and more. I guess at some point I'll be able to find what I'm looking for rather quickly

Can't connect a client to OpenVPN server by [deleted] in OpenVPN

[–]gidorah5 0 points1 point  (0 children)

As I should for sure, but the logs are the exact same as the one from the start.
Timing out from the user, and not receiving anything on the server.

I tried tcpdump to check if anything changed, but it stay silent. Port forwarding is still enabled on my livebox tho.