6.10.94-stable
In this page
GreyCat Python
- If you starting to explore Python SDK for GreyCat we would highly recommend starting with the Python SDK 101 tutorial.
- In addition, there is a Python SDK advanced tutorial which demonstrates how you can push data stored in GreyCat to a Transformers model to train and gather information from the training and predictions back into GreyCat.
You can access Python SDK versions at https://get.greycat.io/files/sdk/python/
How to login to GreyCat
Following the Python SDK 101 tutorial should leave you with all the necessary setup to run GreyCat and Python together.
Start the GreyCat server
Create a simple project.gcl
file. Create a user with the name, hashed password and other properties as shown below. Use the SecrutiyEntity::set()
static function to set the newly created user so that it will be accessible in the runtime.
use runtime;
use util;
fn main() {
var user: User = User {
id: 0,
name: "admin",
activated: true,
external: false,
role: "user",
};
SecurityEntity::set(user);
// Logging
info(Crypto::sha256hex("changeme"));
User::setPassword(user.name, Crypto::sha256hex("changeme"));
}
Run the command to start the server in the same directory as the project.gcl
greycat serve
It will start the server in your local host at port 8080.
Access the GreyCat server in your Python package
In any of your Python package you can call the running server with your credentials and play with it.
from greycat import *
def main(url: str, username: str, password: str):
gc: GreyCat = GreyCat(url, username=username, password=password)
print(f"{gc.call('runtime::User::me')}")
if __name__ == "__main__":
main("http://localhost:8080", "admin", "changeme")