Closed lusentis closed 6 years ago
@alexcasalboni tests are passing on this branch, if you can, rebase your fork :)
@lusentis will do! I also wanted to improve tests and make sure the JSON printed to stdout is always valid, so that you can proceed with the whole pipeline in JS without too much hacking. Then I'll need to work on the Python wrapper too.
Would you prefer making createIndex.getWrappingCode
a bit more generic to handle every possible case, or creating a new createIndex.getWrappingPythonCode
function? How will we choose which one to call? The language/runtime choice should be available along the pipeline.
@alexcasalboni Great!
I'd propose refactoring the current implementation like this:
createIndex.js
should export a function which takes, in addition to the current parameters, the language/runtime (createIndex is called here: https://github.com/dawson-org/dawson-cli/blob/2a6c0ff88f3deb80f4930abdb0cf48954cef6f73/src/libs/createBundle.js#L181)createIndex.js
should then call the appropriate function, which I'd put in a separate file, maybe under a libs/language-python
folderlibs/language-nodejs-latest
(effectively moving towards a language-agnostic dawson) - babel, npm install routines etc would go there tooconfig.js
should do the job of detecting which language to useIn a near future we could also support mixed-language projects? Does this makes sense?
What do you think? (I'll look into this deeper later this afternoon.)
Okay, I've ended up with a slightly different and more clean approach.
I've moved createIndex
to language-javascript-latest
and kept the whole language choice logic in createBundle.js
(and config.js
), so it will be much easier to add more languages in the future.
Feedback is appreciated :D
It looks good, so far!
Regarding mixed-language projects, it would be cool! We should be able to easily detect both api.js and api.py, and parse/generate both on deploy.
Awesome!
But wait.. does it mean that we can't have both at the same time in dev?
no :) currently docker-lambda is invoked once for each function execution and it does no container reuse (it's not supported). We just specify the docker-lambda image to use with each invocation. This is really easy to implement because we determine the image name from the "api.runtime" property!
Edit: implemented in ~10 lines of code 👍 (https://github.com/dawson-org/dawson-cli/pull/136/commits/ceafca03faa36828113f55c87a21e8ad86cd899a)
I've cleaned up this branch:
internal-language-refactor
internal-language-refactor
has been merged into master
master
🎉
Awesome. I've just opened a new PR to add the runtime config param.
@alexcasalboni would you prefer to have write access to this branch?
Yeah, that would make things faster :)
I've just pushed a basic language-python
implementation and I'm able to correctly deploy python functions!
There's still some work to do (clean up, mostly).
Here's a py example I'm using: https://github.com/dawson-org/dawson-examples/tree/master/2-basic-python
dawson dev
now works too 🎉 (except for authorizers)
@alexcasalboni feel free to update any code that needs to be improved etc (I'm not too familiar with python in particular)
Ok, great! I will have another look around and fix those paths asap.
@lusentis please have a look at the last few commits! I didn't have time to properly test the devInstrument for Python, but it should be a good starting point :)
Thank you! I'll have a look this evening.
(my Mac broke and I can't get this to work on Windows..., I'll need a few more days to review this)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@lusentis do you have a new Mac now? ;)
No, it's a PC 💻. I promise I'll work on this in the next days.
Merging #136 into master will decrease coverage by
4.86%
. The diff coverage is26.31%
.
@@ Coverage Diff @@
## master #136 +/- ##
==========================================
- Coverage 92.94% 88.07% -4.87%
==========================================
Files 9 10 +1
Lines 241 260 +19
==========================================
+ Hits 224 229 +5
- Misses 17 31 +14
Impacted Files | Coverage Δ | |
---|---|---|
src/factories/primaryTemplate.js | 100% <ø> (ø) |
:arrow_up: |
src/factories/cf_apig.js | 100% <100%> (ø) |
:arrow_up: |
src/libs/language-python/createIndex.js | 6.66% <6.66%> (ø) |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 8702799...df2534b. Read the comment docs.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
dockerImage
option (see below)Example app: https://github.com/dawson-org/dawson-examples/tree/master/2-basic-python