I'm not sure if it'll be useful to anyone other th...
# show-and-tell
r
I'm not sure if it'll be useful to anyone other than me, but I just published a Prefect API client for .NET: https://github.com/rpeden/prefect-dotnet-client I use it in C# and F# and it works nicely there. But if you choose to (or have to) use VB.NET, it should work fine there too 🙂. It's all auto-generated using OpenAPI generator. It targets .NET Standard 2.0 so it should work in anything from a crufty LOB app that will be stuck on .NET Framework 4.6 until the end of time to a bleeding-edge AOT-compiled .NET 8 app. Right now, it only works with endpoints available in both Prefect OSS and Prefect Cloud - I did a lot of processing of Prefect's autogenerated OpenAPI spec to make it friendly to the OpenAPI generator and I just I haven't had time to do the cloud-only endpoints yet. Regardless, the client is pretty useful as-is. I mostly use it to work with flows, flow runs, and logs and haven't run into any issues. The repo includes a pretty good set of autogenerated docs but if you decide to give it a try and have any questions, please feel free to open a discussion on GitHub.
👋 8
sonic 5
🦜 5
👍 10
squirtle cool 5
j
Awesome, @Ryan Peden!
o
Damn, that looks cool. Will check it out!
k
Nice job! We were trying to do same thing and got blocked by Prefect's OpenAPI spec. https://github.com/PrefectHQ/prefect/issues/10831
r
@Ken Dallmeyer I'll try to find time over the next couple of weeks to polish the cleanup code and customized OpenAPI generator template I used to generate these and add them to the repo. That way it'll be easy to customize everything to your needs in case anything is missing right now. In the meantime, if it's missing anything you need, feel free to open an issue or discussion in the GitHub repo 😀
k
@Ryan Peden are you also planning on creating dotnet flows and tasks? Or just planning on triggering flows from dotnet apps?
r
@Ken Dallmeyer I'd like to. In September I started working on a library called Bronco that'll let you write flows and tasks in .NET languages. But I got busy with freelance work and had to set it aside for a while. I'm trying to keep some time free between mid October and the end of November to do more work on it. Even in its incomplete state it's useful enough that I'm using it to schedule and observe some C# code that runs on my Raspberry Pi and pulls data from sensors. The sensors are a bit flaky, so Prefect's retries and observability are handy 🙂 I've tried to make it follow Prefect's incremental adoption approach, so you can take code that runs just fine standalone and add a
Flow
attribute, like so:
Copy code
public class AmazingFlow
{
    private readonly ILogger _logger;

    public AmazingFlow(ILogger logger)
    {
        _logger = logger;
    }

    [Flow(Name = "The World's Greatest Flow", Retries = 3)]
    public string GreatFlow(string message)
    {
        foreach (int i in Range(1, 5))
        {
            _logger.LogInformation($"{message} {i}");
        }

        return message;
    }
}
and when a Prefect worker or agent runs it, it shows up the Prefect UI as you'd expect along with the log output (see attached screenshot - I used "Hello!" as the
message
parameter when I created the deployment). It does dependency injection, so if you ask for an ILogger, you automatically get a run logger if you're in a flow or task run, and you can of course register your own dependencies and the library will inject them into your flows and tasks. Feel free to DM if you think it might be useful. I'm writing up a list of which features are essential for a 0.1.0 release and which can wait until later, so I'd appreciate your thoughts.
🙌 2
🦜 2