I recently added a new cloud function to my project, and for some reason when I deploy it gets skipped:
firebase deploy --only functions:stripeOperation
which results in
⚠ functions: the following filters were specified but do not match
any functions in the project: stripeOperation
The file structure is like this:
functions/
├── src/
│ ├── stripe
│ │ ├── index.ts
│ │ ├── myTrigger.ts
│ │ ├── anotherTrigger.ts
│ │ └── stripeOperation.ts
│ ├── index.ts
functions/src/stripe/index exports all 3 of the functions in the stripe folder.
functions/src/index exports them from the stripe folder:
export { stripeOperation, myTrigger, anotherTrigger } from './stripe';
Here's where it gets weird - myTrigger and anotherTrigger successfully deploy, but stripeOperation doesn't. There are no build errors. Firebase isn't giving me any clues as to why it's skipped. I checked and the transpiled code looks fine. stripeOperation is a callable function but the other 2 are firestore triggers. This is the signature of stripeOperation:
export const stripeOperation = functions.https.onCall((data, context) => {
...
});
Is there any way to determine why firebase won't deploy my function? I am using "firebase-functions": "^2.3.1"
Update: I have tried renaming the function, and completely switching out the function body with a previously deployed function, and neither worked.
You have to export callable functions separately from trigger functions. This doesn't make sense, so I filed an issue.
functions/src/index:
export { stripeOperation } from './stripe/stripeOperation';
export { myTrigger, anotherTrigger } from './stripe';
Related
I have made a Next.JS typescript monorepo here with the following folder structure:
.
└── packages
├── package.json // Housing the monorepo workspace
├── web-app // Housing the NextJS website
└── web-core // Housing the redux business logic
Whenever I run yarn dev inside the root or inside the web-app, I get the following parsing error:
error - Error: could not find react-redux context value; please ensure the component is wrapped in a <Provider>
at useReduxContext (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/packages/web-app/node_modules/react-redux/lib/hooks/useReduxContext.js:30:11)
at useStore (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/packages/web-app/node_modules/react-redux/lib/hooks/useStore.js:28:28)
at useDispatch (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/packages/web-app/node_modules/react-redux/lib/hooks/useDispatch.js:24:17)
at Home (webpack-internal:///./pages/index.tsx:21:78)
at processChild (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/node_modules/react-dom/cjs/react-dom-server.node.development.js:3353:14)
at resolve (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/node_modules/react-dom/cjs/react-dom-server.node.development.js:3270:5)
at ReactDOMServerRenderer.render (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/node_modules/react-dom/cjs/react-dom-server.node.development.js:3753:22)
at ReactDOMServerRenderer.read (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
at Object.renderToString (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/node_modules/react-dom/cjs/react-dom-server.node.development.js:4298:27)
at Object.renderPage (/Users/hasnainali/Downloads/Projects/Web/jest-rollup-issue/node_modules/next/dist/server/render.js:680:46) {
page: '/'
}
I am doing something wrong with the setup of the monorepo which I am failing to understand. Please help!
I am trying to overwrite from the CLI a group of parameters and I am not sure how to do it. The structure of my conf is the following
conf
├── config.yaml
├── optimizer
│ ├── adamw.yaml
│ ├── adam.yaml
│ ├── default.yaml
│ └── sgd.yaml
├── task
│ ├── default.yaml
│ └── nlp
│ ├── default_seq2seq.yaml
│ ├── summarization.yaml
│ └── text_classification.yaml
My task/default looks like this
# #package task
defaults:
- _self_
- /optimizer/adam#cfg.optimizer
_target_: src.core.task.Task
_recursive_: false
cfg:
prefix_sep: ${training.prefix_sep}
while the optimiser/default looks like this
_target_: null
lr: ${training.lr}
weight_decay: 0.001
no_decay:
- bias
- LayerNorm.weight
and one specific optimiser, say adam.yaml, looks like this
defaults:
- default
_target_: torch.optim.Adam
In the end the config I'd like to be computed is like this
task:
_target_: src.task.nlp.nli_generation.task.NLIGenerationTask
_recursive_: false
cfg:
prefix_sep: ${training.prefix_sep}
optimizer:
_target_: torch.optim.Adam
lr: ${training.lr}
weight_decay: 0.001
no_decay:
- bias
- LayerNorm.weight
I would like to be able to modify the optimiser via the CLI (say, use sgd), but I am not sure how to achieve this. I tried, but I understand why it fails, this
python train.py task.cfg.optimizer=sgd # fails
python train.py task.cfg.optimizer=/optimizer/sgd #fails
Any tips on how to achieve this?
Github discussion here.
You can't override default list entries in this form.
See this.
In particular:
CONFIG : A config to use when creating the output config. e.g. db/mysql, db/mysql#backup.
GROUP_DEFAULT : An overridable config. e.g. db: mysql, db#backup: mysql.
To be able to override a default list entry, you need to define it as a GROUP_DEFAULT.
In your case, it might look like
defaults:
- _self_
- /optimizer#cfg.optimizer: adam
In Hydra I have the following configuration:
├── conf
│ ├── config.yaml
│ ├── callbacks
│ │ ├── callback_01.yaml
│ │ └── callback_02.yaml
│ └── trainer
│ ├── default.yaml
The callbacks have a structure like this:
_target_: callback_to_instantiate
I need to pass to the trainer/default.yaml both the callbacks through interpolation.
I tried like this:
_target_: pytorch_lightning.Trainer
callbacks:
- ${callbacks.callback_01}
- ${callbacks.callback_02}
With the config.yaml like this:
defaults:
- _self_
- trainer: default
I did also other trials but it doesn't seem to work. Is there a way to interpolate like that in a yaml file by using two or more yaml files that are in the config group?
I would like if possible to keep this structure.
Currently the recommended approach is:
compose a mapping whose values are the desired callbacks, and then
use the oc.dict.values OmegaConf resolver to get a list of values from that dictionary.
# conf/config.yaml
defaults:
- callbacks#_callback_dict.cb1: callback_01
- callbacks#_callback_dict.cb2: callback_02
- trainer: default
- _self_
# conf/trainer/default.yaml
_target_: pytorch_lightning.Trainer
callbacks: ${oc.dict.values:_callback_dict}
# my_app.py
from typing import Any
import hydra
from omegaconf import DictConfig, OmegaConf
#hydra.main(config_path="conf", config_name="config")
def app(cfg: DictConfig) -> Any:
OmegaConf.resolve(cfg)
del cfg._callback_dict
print(OmegaConf.to_yaml(cfg))
if __name__ == "__main__":
app()
At the command line:
$ python my_app.py
trainer:
_target_: pytorch_lightning.Trainer
callbacks:
- _target_: callback_to_instantiate_01
- _target_: callback_to_instantiate_02
For reference, there is an open issue on Hydra's github repo advocating for an improved user experience around
I have a serverless REST API that uses NodeJS and Google Cloud Functions (Firebase). It works on production. But not locally for testing.
The app was created following the tutorial at: https://dev.to/levivm/creating-a-serverless-rest-api-using-google-cloud-functions-firebasefirestore-in-10-min-37km
When the firebase emulator is started locally the API endpoint seems not to work, and an error is returned:
URL http://my_local_server:8080/api/v1/my_api_route.
Output: Cannot GET /api/v1/my_api_route
The root url returns: http://my_local_server:8080/
{"status":"alive"}
Do you know what might cause the issue?
$ firebase emulators:start --only functions
i emulators: Starting emulators: functions
✔ functions: Using node#10 from host.
✔ functions: Emulator started at 0.0.0.0:8080
i functions: Watching "/home/ubuntu/environment/Crew-IQ/functions" for Cloud Functions...
⚠ functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
✔ functions[webApi]: http function initialized (0.0.0.0:8080/crew-iq/us-central1/w...).
✔ All emulators started, it is now safe to connect.
For that application, the endpoint would be
http://localhost:8080/crew-iq/us-central1/webApi/api/v1/my_api_route
└───┬───┘ └─┬┘ └──┬──┘ └────┬────┘ └──┬─┘└─────────┬────────┘
host │ │ │ │ │
port │ │ │ │
project ID │ │ │
function region │ │
function name │
your express app
I'm trying to debug firebase function on my local windows
as described in https://medium.com/#mwebler/debugging-firebase-functions-with-vs-code-3afab528bb36
I do
set FIREBASE_CONFIG={ databaseURL: 'https://invoice-manager-251609.firebaseio.com', storageBucket: 'invoice-manager-251609.appspot.com', projectId: 'invoice-manager-251609'}
functions start
and get
┌────────┬────────┬─────────┬─────────────────────────────────────────────────────────────────┐
│ Status │ Name │ Trigger │ Resource │
├────────┼────────┼─────────┼─────────────────────────────────────────────────────────────────┤
│ FAILED │ upload │ HTTP │ http://localhost:8010/invoice-manager-251609/us-central1/upload │
├────────┼────────┼─────────┼─────────────────────────────────────────────────────────────────┤
│ FAILED │ tst │ HTTP │ http://localhost:8010/invoice-manager-251609/us-central1/tst │
├────────┼────────┼─────────┼─────────────────────────────────────────────────────────────────┤
│ FAILED │ tst1 │ HTTP │ http://localhost:8010/invoice-manager-251609/us-central1/tst1 │
└────────┴────────┴─────────┴─────────────────────────────────────────────────────────────────┘
if I do
firebase emulators:start
I get
undefinedWarning, estimating Firebase Config based on GCLOUD_PROJECT.
Initializing firebase-admin may fail[2019-10-06T11:44:51.932Z]
#firebase/database: FIREBASE FATAL ERROR: Cannot parse Firebase url.
Please use https://.firebaseio.com
I also tried:
functions debug tst1
and get:
ERROR: Function worker crashed with exit code: 9
undefined(node:21096) [DEP0062] DeprecationWarning: `node --debug
and
node --debug-brkare invalid. Please usenode --inspectornode --inspect-brk` instead.
I tried with node-10 and node-8
I also tried this:
https://medium.com/#david_mccoy/build-and-debug-firebase-functions-in-vscode-73efb76166cf
and this
https://rominirani.com/google-cloud-functions-tutorial-debugging-local-functions-357c24829198
I get the same errors
whats going on?
how do I debugging firebase on local windows?
The guides in the question are correct, but
when running in Emulator, u have to set the db url manually
admin.initializeApp({
databaseURL: "https://<YOUR FIREBASE>.firebaseio.com"
});
here is the full cmd list:
functions start
functions deploy --trigger-http --timeout 600s funcName
functions inspect funcName
After that u can use chrome://inspect/ to connect to the process with the chrome debugger.
If you have issues, u can use:
functions logs read
NOTE: after functions start I still get the table with FAILED status - I ignore it