Skip to content

Commit

Permalink
chore(python): use sim.Container (#261)
Browse files Browse the repository at this point in the history
Use the `sim.Container` to show containers logs. Also use docker image instead of local python to build the python dependencies.
  • Loading branch information
eladcon authored Jun 13, 2024
1 parent c6c8901 commit 457ee3a
Show file tree
Hide file tree
Showing 13 changed files with 200 additions and 421 deletions.
5 changes: 5 additions & 0 deletions python/builder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM public.ecr.aws/lambda/python:3.12

COPY requirements.txt /app/requirements.txt

RUN pip install -r /app/requirements.txt
8 changes: 8 additions & 0 deletions python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@winglibs/python",
"description": "python library for Wing",
"version": "0.0.7",
"version": "0.0.8",
"repository": {
"type": "git",
"url": "https://github.com/winglang/winglibs.git",
Expand Down
299 changes: 0 additions & 299 deletions python/sim/containers.w

This file was deleted.

32 changes: 23 additions & 9 deletions python/sim/function.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const { App } = require("@winglang/sdk/lib/core");
const { Function: SimFunction } = require("@winglang/sdk/lib/target-sim/function.js");

module.exports.handleSimInflight = (inflight, props) => {
for (let e in props.env) {
inflight.inner.service.addEnvironment(e, props.env[e]);
}
module.exports.Function = class Function extends SimFunction {
constructor(
scope,
id,
inflight,
props = {},
pythonInflight,
) {
super(scope, id, inflight, props);

this.pythonInflight = pythonInflight;

if (!App.of(inflight).isTestEnvironment) {
for (let key of ["AWS_REGION", "AWS_DEFAULT_REGION", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]) {
let value = process.env[key];
if (value) {
inflight.inner.service.addEnvironment(key, value);
if (!App.of(this).isTestEnvironment) {
for (let key of ["AWS_REGION", "AWS_DEFAULT_REGION", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"]) {
let value = process.env[key];
if (value) {
this.addEnvironment(key, value);
}
}
}
}

_preSynthesize() {
this.pythonInflight.inner.preLift(this);
return super._preSynthesize();
}
}
Loading

0 comments on commit 457ee3a

Please sign in to comment.