mykey.get() method doesn't work in google app engine project
A few things are wrong here.
Firstly Subcategory.get_by_id(subcategoryId) probably won't work as you example key has an ancestor defined.  You need to include the ancestor(s) in get_by_id
Given you are using a mySubcategorykey.get() and you don't retrieve an entity then it means the key is incorrect.  a get by key won't experience eventual consistancy so the key is just wrong, or you didn't put() the original entity.  
I suggest you examine the key after you put() the entity and see if it actually matches what you are using.
Also there are problems with your example key, ndb.Key(Category, 'Foods', Subcategory, subcategoryId)  Category and Subcategory need to be strings, or variables with a string value of "Category" and "SubCategory" - which would be a bit odd to write this way.
Also you don't create query objects from keys , query is a method of ndb.Model, or you instantiate a query object from ndb.Query .
So you are mixing up some terminolgy and/or concepts.
I am passing one of my projects to the google app engine, just for the sake of learning. However I have some problems with the ndb datastore. My root entity would be Categories and these have Subcategories as child entities. So let's say I have Category Foods which has Subcategory Main Dishes. So the key for this Entity would be ndb.Key(Category, 'Foods', Subcategory, subcategoryId). When I am creating a query object from this key I can fetch the correct subcategory, but from the documentation I would like to do other two methods as well which are not working, I don't know for what reason.
mySubcategorykey.get() => it returns None using the aforementioned key.
Subcategory.get_by_id(subcategoryId) => Also returns None.
Also when I am generating a safeUrl from the key, I cannot return the object with ndb.Key(urlSafe=myUrlSafeString).get(), however printing the ndb.Key(urlSafe) gives me the correct key, as it states in the DataStore Viewer.
Anyone can help me please telling what I am doing wrong? Thank you.