New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] rough cut improved F# support #279
Conversation
Hi @dsyme, I'm your friendly neighborhood Azure Pull Request Bot (You can call me AZPRBOT). Thanks for your contribution! TTYL, AZPRBOT; |
@dsyme thank you for sending this! Really excited about improving the F# experience in Azure Functions! I'm taking a closer look at the changes, but some of the things here like breaking the C# compilation logic out of the invoker (what you've done in your change with the Addressing your questions/comments above:
This is the default Roslyn main scripting type. We use that name to get that type specifically and look for the entry point method within it. Methods defined in your C# function script are ultimately part of this type.
This is what we were investigating :) So I think it is appropriate but would follow your guidance here.
If I understand your question correctly, the answer is yes. This was the plan in order to support additional .NET languages (F# included), so the plan was to refactor types like the There are also a few other changes to the invoker model we've been working on, but those are primarily to align the Node and other scripting invokers with the model used by C# today, so I wouldn't expect them to impact this work. Again, we're very excited about your contribution here! Better F# support has been one of our top customer requests, so a lot of people will be very happy to see this done! Please let me know if there's anything we can do to make this process easier or if you run into any issues as you move forward. |
@dsyme I had the compilation service abstraction changes out for your review, but what you have is very close to those changes, so to avoid creating more unnecessary work for you, I was wondering if it would be possible to break those changes out into their own PR as they would be beneficial out of the scope of F#. That's assuming you feel you still have a fair amount of work left on the F# implementation. Thanks! |
@fabiocav I think there's not too much more work to do. I need to look into testing now, and there seem to be issues with propagating diagnostics. Could you send me a link to the changes you were making? I can deal with a merge if needs be, Cheers |
@fabiocav BTW it would be really great if we could get GitHub-integrated CI on this repo, so that the full tests are being run on each PR and commit. That would help give confidence that there are no regressions going on :) |
|
||
MethodInfo entryPointReference = entryPointResolver.GetFunctionEntryPoint(methods).Value; | ||
|
||
// For F#, this currently creates a malformed signautre with fewer parameter symbols than parameter names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small typo: signature
@fabiocav BTW I'm not sure why it's saying CLA-required - I'm a Microsoft employee - AFAIK it should be automatically CLA-not-required? |
@dsyme looks they have that painful old CLA process where you have to let your manager sign. That will take ages for me. |
@fabiocav I've got a few questions about the reference model.
|
The CLA process is the standard one for the whole Azure organization, and is pretty painless. |
unfortunately it says I have to let my boss sign. That's not painless for me (and not painless for my boss). IIRC the visualfsharp repo got rid of that requirement a while ago. maybe @KevinRansom or @latkin can tell which lawyer they bribed. |
Disclaimer: I am not a Lawyer :-) @davidebbo I think most of Devdiv OSS uses the Microsoft cla: https://cla.microsoft.com. You might want to evaluate whether the Microsoft CLA is sufficient for Azure OSS contributions. It has the benefit of not requiring current employers to sign on behalf of their OSS contributing employees. |
Sorry, I have no control over this process. It is not specific to this repo, but used widely over the huge Azure org. |
@dsyme we can appropriately label the PR since it didn't recognize you. You may need to link MSFT and GitHub accounts here: https://azureopensource.azurewebsites.net/ so the azureclabot will recognize you in the future. |
@dsyme this is a great step forward. Some things that spring to mind: -
|
@dsyme to answer your questions above:
This is pretty high level, just trying to give you a good overview of how things currently work, but we can dive into details from here when/if needed. |
@fabiocav how are you going to handle updates to e.g. Newtonsoft.Json - how will developers know which version will be bundled for free? |
There are a couple of proposals on how we'll manage that, but we haven't settled on the approach yet, so I don't have much to share, but this is absolutely something we'll be addressing. The entire versioning story goes beyond shared assemblies, into the runtime, Web Jobs SDK, extensions, etc. We're actively working on that and will start sharing details as soon as we can. |
@isaacabraham @fabiocav Quick question, basically unrelated but useful for my testing.
|
It's off topic for this PR, but at first sight this sounds like it might be a false-efficiency. I get the feeling that you might not be doing the programmer any favors by making trying to make this simpler: they will just hit version conflicts and/or confusion later on. Adopting an approach based purely on high-quality, version-consistent package management like project.json (and optionally Paket eventually) seems better. (If the references are dictated by the fact they are in-process references utilized by the AF compilation/loading machinery then that's a slightly different matter, and in that case a different approach to isolation may be needed. http://mbrace.io and other cloud execution machinery had similar issues, generally solved by minimizing the work loading machinery and using app Best |
@dsyme Here's a gist of what I was using for testing it out... https://gist.github.com/isaacabraham/24a376d3fb6ca882528e42ccf4a8a9e0. I actually just created a local git repo in the functions website and deployed from there - folders map to functions within the portal. And yes I saw exactly the same thing regarding read-only - it's referring (I believe) to the broswer editor only. You can push changes via Git and it picks them up no problem. |
@isaacabraham Thanks. Have you by any chance got an example of a whole repo? e.g. with private bin directory and so on. I was mainly trying to understand what is and isn't allowed in the directory structure of the repo. |
Yeah, I'm just looking for it - it's somewhere on this machine! When I find it I'll pop it on GH. |
FYI, I have started a mail thread with @martinwoodward, @forki and @KevinRansom to discuss the CLA part. |
Hi @dsyme, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
Great!!! That gives us something to work on next week :) cc @tpetricek |
Not a bad score for a rough cut :). I see we also successfully managed to break one Node test 👍 |
👍 |
@dsyme , @tpetricek; just wanted to check in and see if you need any help with this. Let us know if there's anything we can do. |
…es into F#. Enabling F#
Hi @dsyme, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
OK, I've merged the work of @fabiocav into the right branch and this PR is reinstated back to Work In Progress :) |
new HttpResponseMessage(HttpStatusCode.BadRequest, Content = new StringContent("Please pass a name on the query string")) | ||
|
||
return res | ||
} |> Async.StartAsTask |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dsyme it's possibile to add the Async.StartAsTask
as another special case of the return type inside the host when the function is called, instead of inside the function itself?
c# does something like that to support async vs sync version of Run
.
ref DotNetFunctionInvoker implementation
so it's possibile to write
let Run (req: HttpRequestMessage , log: TraceWriter) = async {
return "ciao"
}
I have merged this into the fsharp branch (https://github.com/Azure/azure-webjobs-sdk-script/tree/fsharp) and made the necessary fixes to resolve some of the compilation and test issues. There are a few tests failing https://ci.appveyor.com/project/appsvc/azure-webjobs-sdk-script-y8o14/build/1.0.10326 but we should now be able to iterate and submit PRs against that branch to get things going. |
This is a very early rough cut of improved F# support which utilizes the Roslyn-like FSharp.Compiler.Service compiler to do dynamic compilation.
Below is a screen grab of this in practice:
for this function (the transliteration of the C# source)
The execution time for a function goes down from >5sec to the same as C# (milliseconds).
The Roslyn-specific parts of the C# support is factored out into
CSharpCompiler
andCSharpCompilation
. The F# support implements corresponding interfaces. This allows nearly all the resolution machinery for nuget packages and so on to be shared between the two settings.There is a lot more to do but I thought I'd give early visibility to this work since there are various ways of doing this. Some outstanding issues are
async { ... }
rather than tasks (the two are inter-convertible butasync { ... }
is more natural to the F# programmer)ScriptClassName
(Submission#0
) comes from and why we search the C# generated types for that name.Some things we should clarify early