How do I set up a project for gcloud datastore emulator? - emulation

I'm trying to do some offline development with gcloud sdk where I want to build a Python Flask app presenting data queried from a datastore. The reason for doing it offline is simply that it's faster during development, it will be deployed online later using App Engine.
First of all: The datastore emulator is running.
However I am having trouble importing data into the datastore. I am using below from here to try and import (with my values).
curl -X POST localhost:8081/v1/projects/[PROJECT_ID]:import \
-H 'Content-Type: application/json' \
-d '{"input_url":"[ENTITY_EXPORT_FILES]"}'
The problem I am having is that it just returns
NOT FOUND
I think I know what it is but not how to solve it: I don't have a project defined in my offline environment. So I wonder, how do I set up a project in my "offline cloud SDK environment"?

The PROJECT_ID for the DataStore Emulator is set during it's installation.
I've looked a bit into it and in the link at the bottom you can see how it's done. You need to set your project-id as an environment variable, or do it with an automatic command that sets it for you.
Have a look here, I think this is what you're missing.
Hope this helps.
EDIT:
Hey again Nelumbo, I think that the NOT FOUND you received before and the NotFoundHandler are the same error. The common errors in Datastore reflect that NOT_FOUND is generated when an request attempts to update an entity that does not exist which means that it might be a malformed address.
Taking into account that your Datastore emulator starts correctly, that is my first thought of a probable cause, that we are pointing wrong or in the wrong format.
If you are completely sure that is not the case and I'm assuming you attempted different formats and double check.
I have a few other ideas of things that you can checked out in order to discard potential causes.
Are you running in a different port than 8081?
What is your cloud sdk components version? Have you updated them lately?
Have you attempted to pass manually the project ID in the curl?
Also, I'm understanding that you are importing data into the datastore emulator and everything is done locally.
Let me know.
EDIT2:
Hey Nelumbo, the only different things that I can think of that might be affecting you or for you to try is that I'm seeing that the configured port for the installation is 8432 and the one for the import is 8081 as you can see in the following docs. When you checked the environment variables was it 8432 or 8081?
Another thing that I would suggest is attempting to do this in the Cloud Shell to make sure it works and if it does raise a public issue tracker with the GCP team as it might be an issue with the Windows version.
And at least try to update the SDK version to the latest one maybe it's related to that. But yeah, as the initial question of how to add a PROJECT ID to the emulator is solved, making a new one in order to also bring more visibility to it might be helpful.

Related

Cloud Firestore for android apps built in Kivymd not working with buildozer

Me and a friend are creating android app in Kivymd. We did create a database using firebase.
But we used the firestore option than the realtime database. We really like the feature and want to keep it. Everything works fine when we compile the app on our Ubuntu environment. But when we add firebase-admin in our requirements in the buildozer.spec file we get alot of errors related to google-cloud, google-protobuf and the list goes on. We have been looking everywhere on the internet but we cant find a solution. And all of these packages are installed with pip and we have verified this.
When using our original requirements string such as:
requirements = python3,kivy==2.0.0rc3,kivymd,sdl2_ttf==2.0.15,android,plyer,requests,urllib3,chardet,idna,hostpython3
Everything works fine, but when we add firebase_admin to the requirements we get No module errors that makes the requirements string getting very long. And we have installed everything u can possibly think related to the google packages with pip.
We have been exploring on maybe creating our own recipe, but we would be very happy if anyone could just lead us in the right direction. Our current requirements string is so long that i wont post it here. We have made realtime database work because it only uses requests so maybe we need to skip using firestore. Below are the packages we use to use and are the root cause of why the app does not work in the android app with buildozer.
import firebase_admin
from firebase_admin import credentials, firestore, exceptions
I have a feeling we must create a recipe or that its not even possible to use with kivymd and android. But any help would be very appreciated.

Youtube API Node.js quickstart not working: "The API returned an error: Error: invalid_grant"

I followed the tutorial Node.js Quickstart, including installing the libraries googleapis and google-auth-library. I believe I followed the instructions for setting up the credentials properly to my best ability, but I lack the experience to know for sure.
I was unable to exactly follow the tutorial, specifically this line:
e. Select the application type Other, enter the name "YouTube Data API Quickstart", and click the Create button.
because the drop down selection box had no "Other" type.
I had a project using this system working in the past, but it suddenly stopped working. I had not used the program for months, so it is possible something happened in the meantime, but I also absentmindedly revoked the program's access to my Google account.
I am not using the same credentials as before it broke -- in the developer console, I not only deleted the old credentials and downloaded brand-new ones, I created a new project altogether.
Here is an image of the credential:
Of course, I downloaded and renamed the client_secret JSON as instructed.
Here are my project files:
Since I directly copied the code, I have not tried changing it, though I did look through it to make sure there were no IDs I needed to copy in or anything of the sort.
I tried looking through this article, but I had no idea where to even begin the stated debugging processes, as my only experience with OAuth, Node.js, and the YouTube API is this project, and I don't even understand how I got it working originally.
If anyone has any ideas on ways I could try fixing this, or more thorough instructions on how I could begin debugging, I would be immensely grateful.
If relevant at all, I am using the WebStorm IDE.
Screenshot of the terminal:

500 error when I try to deploy nextjs ssg application with incremental-static-generation

I have NextJS app with SSG. This functionality was added recently and according to it I should do next-export after next-build to get static files. But after appearing in 9.4 of Incremental Static Regeneration I need to keep server on by npm-start command (in my case I use custom server file with next-express functionality). It works good locally and It works good when I get artifact from Azure. But It doesn't work globally when it will be deployed finally. Help please
Through my attempts, I found that it is impossible to install globally or use next in Azure Web App. That is, it cannot be deployed through Github.Deploying using other methods such as FTP cannot run successfully. It should be related to the azure node environment.
But the method provided in this post says that it can be processed by adding web.config. I think it should be useful and helpful to you. Please read it carefully and try it.
You also can read this document, maybe it useful to you.

Typo in _admin/metrics

I've started setting up different tools on my home server to create apps for personal use and experience. I'm using telegraf to pull metrics from arangodb's _admin/metrics but getting an error. This is due to one line in the response has a typo which has "guage" instead of "gauge".
https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#RestAdminMetrics_container
#TYPE arangodb_client_connection_statistics_client_connections guage
Will this be fixed in the next update? Also, if there is any workaround for now, please share. thanks
This has been fixed in PR https://github.com/arangodb/arangodb/pull/10625 which will be part of v3.7. I don't know if this will also be backported to 3.6, so you might want to create an issue on github.

How to use firestore local emulator in Node.js?

I would like to try firestore local emulator but resources are a bit scattered and it is hard to determine if it is possible in Node.js.
Has anyone already done that?
After some nice search, it is pretty easy in fact.
Here is a link to a sample projet I made on github which makes a basic insertion followed by a retrieval.
It uses a docker container to run firestore emulator and #firebase/testing package to interact with it. The setup is straightforward and explained in the README.md.

Resources