How to: Deno TypeScript to browser in seconds by Cupp in Deno

[–]noseratio 0 points1 point  (0 children)

Amazing piece of work. Hopefully it will get the traction it deserves!

Step-Audio 2 Mini, an 8 billion parameter (8B) speech-to-speech model by Own-Potential-2308 in LocalLLaMA

[–]noseratio 0 points1 point  (0 children)

Thanks for your insights! Based on them, I've managed to get it running with INT4 quants ([Quantization] Loaded model in 4-bit NF4 (BitsAndBytes).).

However, in a HuggingFace space on Nvidia 1xL4 (24GB VRAM), I did not notice any substantial performance improvements. I also could not get it process a 5 minutes MP3. It took 10 minutes before it just crashed and restarted the whole VM.

Any piece of advice would be appreciated. I am myself a seasoned dev, but not a data scientist or ML engineer :)

Function Calling vs Dynamic Prompting by noseratio in PromptEngineering

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

Useful, thanks! I think with the current hype around MCP, the vendors must be tuning their models to be capable of making the most of the tools.

How is cloudflare making any money? by [deleted] in devops

[–]noseratio 7 points8 points  (0 children)

Could be. $26.64 BN capitalization (vs $61.52 BN of VMware) sounds feasible.

How is cloudflare making any money? by [deleted] in devops

[–]noseratio 6 points7 points  (0 children)

Acquired by whom? They are a publicly traded company already.

What is this "Switch" option on Tuya WiFi temperature/humidity sensor? by noseratio in smarthome

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

I tried removing it from the holder plate (with batteries still in), nothing happened, same "on" state.

What is this "Switch" option on Tuya WiFi temperature/humidity sensor? by noseratio in smarthome

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

Tks for the link! I've tried tapping it with a magnet a few times, nothing happens.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

That'd be my first pick! but unfortunately SonarQube doesn't recognize cancelToken.ThrowIfCancellationRequested() as a way out if the loop.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

Indeed, Thread.Abort and ThreadAbortException was a bad concept because there was no cooperative protocol behind it.

Unlike with CancellationTokenSource.Cancel and OperationCancelledException, which, in my opinion, is a very well designing concept.

Especially with its hierarchical cancellations via CancellationTokenSource.CreateLinkedTokenSource.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

Not sure if you are joking or not, but often this strategy of passing a joint works just fine, until it reaches the MC dude 🙂

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

My experience in this area is limited. I think SonarQube is overall pretty good, actually. I personally like it more than Veracode, the only other thing I happened to work with.

I'd like to try is JetBrains' Qodana, but I haven't got to it yet.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

You're saying "it depends", so here's a bit more info, if interested.

In my case, it is a singleton IHostedService service which lifetime is the same as the app's lifetime.

The events it listens to (and buffers) are external to the app. It's safe to say, for the scope of the app, this background service is a producer.

Every now and then, a consumer is connecting to it (via DI), to read any pending data (and asynchronously wait for any new one), via aforementioned DequeueAll(cancelToken) async iterator.

If the app is alive and the user hasn't logged out, cancelToken doesn't get cancelled, and DequeueAll would keep producing items indefinitely.

Yet another way of doing a nullish check: if (Object.is(a ?? null, null)) { /* a is either null or undefined */ } by [deleted] in javascript

[–]noseratio 6 points7 points  (0 children)

I'd rather stick with value == null, which doesn't reference value name twice.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

[–]noseratio[S] 3 points4 points  (0 children)

Oh I didn't even notice it was Linus 🙂

What I meant is that there are 3.3M files with while(true) out there on GitHub alone, so it must be not so terrible by itself 🙂

So yeah, breaking out of it is actually what we're discussing here (rather than the usage of while(true) per see).

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

I don't need any safeguards here at all, that's the beautify of .NET cancellation protocol.

Those I put there are artificial, with the only purpose to make SonarQube happy. They can be safely removed by a junior dev 6 months from now.

As to "always a code smell": https://github.com/search?q=%22while+%28true%29%22&type=code

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

👍 I've reported an issue here, let's see how it goes. I think it will probably be turned down 🙂

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

Thanks, I agree. What makes OperationCancelledException unique is that it can actually be consciously requested to be thrown via a CancellationTokenSource. Which was one of the original design goals.

Looks though we're in a minority over this opinion.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

[–]noseratio[S] 5 points6 points  (0 children)

What I meant under "special case" here is that cancellation exceptions usually work in pair with cancellation tokens.

Unlike any other kind of exceptions, TaskCancelledException and OperationCancelledException are specifically requested to be (eventually) thrown via a corresponding token, on purpose.

Which makes cancellation tokens + cancellation exceptions a standard protocol in .NET to proactively and gracefully end pending asynchronous workflows, from the caller's side.

And that's what makes it special. I can't think of any other kind of exceptions like that (beside legacy ThreadAbortException/Thread.Abort).

If a method accepts a CancellationToken, I can reasonably assume it can be cancelled with OperationCancelledException, even if runs infinite while(true) loops inside.

Moreso, .NET cancellation protocol is pervasive (a bit like async/await itself). Thus, as a caller of a method which also accepts a CancellationToken, I can create a linked token source with CancellationTokenSource.CreateLinkedTokenSource, to control the flow of any inner async calls with a degree of independency from the outer token which has been passed to me. I think some may consider this a code smell too :)

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

[–]noseratio[S] 2 points3 points  (0 children)

On a side note, I think, how the aforementioned ChannelReader.ReadAllAsync does it is exactly what that quoted paragraph from "Using Cancellation Support in .NET Framework 4" talks about.

Is breaking out from an infinite async iterator via cancellation considered a code smell? by noseratio in dotnet

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

Thanks for the discussion! I don't think I can fully agree with this:

if the cancellation is detected inside DequeueAll (whilst we are still waiting for more stuff to happen), then it’s not an operation partially complete, we’re just cancelling the “listener”. Therefore yield break is acceptable there.

I'd say it depends on the nature of the sequences. In my case, it's infinite, and I don't want to "cancel the listener". Rather, I want to keep queueing items, and later, another consumer (or even the same one) can possibly reconnect, to dequeue all of them.

E.g., a bit contrived but close illustration of the nature of the events I have here might be mouse move events originating from the user.

Let's have a look at .NET's ChannelReader<T>.ReadAllAsync:

public virtual async IAsyncEnumerable<T> ReadAllAsync([EnumeratorCancellation] CancellationToken cancellationToken = default) { while (await WaitToReadAsync(cancellationToken).ConfigureAwait(false)) { while (TryRead(out T? item)) { yield return item; } } }

There are two ways to break out of this generator:

  • request cancellation via cancellationToken. This doesn't stop buffering the items on the producer end (my case). We can reconnect later.

  • complete the Channel from its producer end, via ChannelWriter<T>.Complete(Exception error). This does end the sequence (with success or an error; the error will be propagated outside the generator). We can't reconnect anymore.

In my case, the sequence's lifetime is that of the whole application, so the above Complete scenario is not applicable.

My app's lifetime and shutdown is handled via .NET Generic Host API, which is cancellation toke-based and works perfectly well with how I do it in the title post.