question

Joel-5117 avatar image
0 Votes"
Joel-5117 asked Joel-5117 commented

How to upload a .pyd file format onto the server?

Hi,

I'm new to SQL Machine Learning Server and also quite new to Python.

Currently my company is acquiring SQL Machine Learning Server to deploy AI models onto the server. The AI Model that i am working on right now is being developed by an external vendor, and that vendor only provide me their model wrapped in a ".pyd" file or executable file in ".pyd" format to keep the codes encrypted. To use the model, i simply call the model by importing its function/method.

So the question is... how do i upload the ".pyd" file onto the server?

sql-server-generalsql-server-analysis-services
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Joel-5117!

I am looking at how you can do this. I am getting some strange errors, so let me investigate a bit more and come back to you.

Niels

1 Vote 1 ·

Hi @Joel-5117, we have not get a reply from you, any update for this thread?

0 Votes 0 ·

Hi @CarrinWu-MSF, I just replied to your suggestion. Thanks!

0 Votes 0 ·
CarrinWu-MSFT avatar image
0 Votes"
CarrinWu-MSFT answered Joel-5117 commented

Hi @Joel-5117,

Welcome to Microsoft Q&A!

Please refer to Python tutorials for SQL machine learning, I think the tutorials could help you to run python script into SQL Server.
108048-python.png


Best regards,
Carrin


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



python.png (78.8 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Thank you for the comment! Appreciate it.

Understand that the server can run python scripts. However, the ".pyd" format that i'm referring to is actually more like an executable file. The codes are encrypted, so i can't copy paste the codes out and execute them to upload onto server. So i am not sure how i can upload this type of format onto the server.

0 Votes 0 ·

Hi @CarrinWu-MSFT! Don't be sorry :) Thank you for your research, i will explore the links to see if it helps! Thank you!

0 Votes 0 ·
NielsBerglund-3563 avatar image
0 Votes"
NielsBerglund-3563 answered Joel-5117 commented

Hi there @Joel-5117!

OK, as I wrote above, I did some further investigations - and I made it to work. However to get it to work I used an open source Python version in SQL Server. In SQL Server 2019 CU3+ you have the ability to install your own Python, (and R), runtime, and not use the "standard" Microsoft runtime. For more of that see my post here: https://nielsberglund.com/2020/12/29/updated-bring-your-own-r--python-runtimes-to-sql-server-extensibility-framework/.

Anyway, what you do is you import your .pyd file as you would with any import and the use it. An example below:

 EXEC sp_execute_external_script 
 @language =N'p39',
 @script= 
 N'
 import sys 
 import os
 sys.path.append(os.path.abspath("W:/pythontest"))
  from hello import hello42
    
 hello42()'

In the snippet above I have:

  • created my own Python language, which I call p39 (as per my blog posts)

  • I have a .pyd file named hello.pyd, and it is located in w:\pythontest.

  • In that file I have a function called hello42.

In my Python script I do some imports followed by from ... and then I just use it. The one thing to think about is that you need to assign the permissions to "ALL APPLICATION PACKAGES" to the directory where your .pyd file is as well as the file itself like so:

 icacls w:\pythontest /grant *S-1-15-2-1:(OI)(CI)F /t


Hope this helps!

Niels


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @NielsBerglund-3563!

Appreciate your investigations and experimentations! I will discuss with my colleagues and attempt to test with your methods/suggestions! :) Thank you so much for your guidance and effort!

0 Votes 0 ·