GoogleCloudPlatform / functions-framework

The Contract for Building New Function Frameworks
Apache License 2.0
120 stars 12 forks source link

How to tell functions-framework which language to look for? #52

Closed made-by-chris closed 2 years ago

made-by-chris commented 2 years ago

I set up a local gcloud project and tested some functions in python, running functions-framework that was installed through pip.

Then I did exactly the same thing but with javascript functions, and attempted to run them locally with npx @google-cloud/functions-framework (npx @google-cloud/functions-framework --target=myfunction, ran from the directory containing the nodeJS project with the index.js containing my cloud functions).

Upon invocation of the js method, I got this error

Traceback (most recent call last):
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code     
    exec(code, run_globals)
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\Scripts\functions-framework.exe\__main__.py", line 7, in <module>
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\site-packages\functions_framework\_cli.py", line 37, in _cli
    app = create_app(target, source, signature_type)
  File "C:\Users\basic\AppData\Local\Programs\Python\Python39\lib\site-packages\functions_framework\__init__.py", line 198, in create_app
    raise MissingSourceException(
functions_framework.exceptions.MissingSourceException: File C:\Users\basic\projects\nodejs.gcloud.local.functions.development.guide\main.py that is expected to define function doesn't exist

Am I somehow able to tell functions-framework which language it should be looking for ? I checked the functions-framework --help but couldn't work out anything from there.

Thanks!

made-by-chris commented 2 years ago

Oh! Setting functions-framework as a dev dependency and then npm installing seemed to solve the issue, preventing collision with the globally-installed pip package something something.