Skip to content

Commit 0cec4c4

Browse files
committed
bourbaki breaker and holo_atom recompiler
1 parent b937711 commit 0cec4c4

File tree

9 files changed

+119
-20
lines changed

9 files changed

+119
-20
lines changed

.devcontainer/devcontainer.json

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
{
2-
"name": "Python 3.13 with JupyterLab, Ruff, Black, and Mypy",
2+
"name": "Py 3.13 with Jupyter kernel + JLab, R, B, M, and Docker + VScode/dev-env/git CICD",
33
"image": "mcr.microsoft.com/vscode/devcontainers/base:ubuntu",
4-
"settings": {
5-
"terminal.integrated.defaultProfile.linux": "bash",
6-
"python.pythonPath": "~/.pyenv/versions/3.13.0/bin/python",
7-
"python.linting.enabled": true,
8-
"python.linting.ruffEnabled": true,
9-
"editor.formatOnSave": true,
10-
"editor.defaultFormatter": "ms-python.black-formatter"
4+
"customizations": {
5+
"vscode": {
6+
"settings": {
7+
"terminal.integrated.defaultProfile.linux": "bash",
8+
"editor.formatOnSave": true,
9+
"python.pythonPath": "~/.pyenv/versions/3.13.0/bin/python",
10+
"python.linting.enabled": true,
11+
"python.linting.ruffEnabled": true,
12+
"editor.defaultFormatter": "ms-python.black-formatter"
13+
},
14+
"extensions": [
15+
"ms-python.python",
16+
"charliermarsh.ruff",
17+
"ms-python.black-formatter",
18+
"matangover.mypy",
19+
"ms-python.debugpy"
20+
]
21+
}
1122
},
12-
"extensions": [
13-
"ms-python.python",
14-
"charliermarsh.ruff",
15-
"ms-python.black-formatter",
16-
"matangover.mypy"
17-
],
18-
"postCreateCommand": "bash .devcontainer/setup.sh && cp .devcontainer/.bashrc ~/.bashrc && source ~/.bashrc && pip install -e . jupyterlab mypy black",
23+
"postCreateCommand": "bash .devcontainer/provisioning.sh && bash .devcontainer/setup.sh && cp .devcontainer/.bashrc ~/.bashrc && source ~/.bashrc && pip install -e . || true",
1924
"postStartCommand": "jupyter-lab --ip=0.0.0.0 --no-browser --allow-root",
2025
"forwardPorts": [8000, 8888, 8341],
26+
"runArgs": ["--network=host"],
27+
"onCreateCommand": "if [ \"$CODESPACES\" = \"true\" ]; then echo 'In Codespaces: Running minimal setup'; else bash .devcontainer/provisioning.sh; fi || true",
2128
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind",
2229
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
2330
"remoteUser": "vscode",
2431
"features": {
2532
"ghcr.io/devcontainers/features/python:1": {
2633
"version": "3.13"
2734
}
35+
},
36+
"remoteEnv": {
37+
"OLLAMA_SERVER": "http://host.docker.internal:11434"
2838
}
2939
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3.8"
2+
3+
services:
4+
app:
5+
# For native Ubuntu, you can enable host networking. Uncomment if desired:
6+
# network_mode: "host"
7+
8+
# For Windows (Docker Desktop), override the Ollama URL to use host.docker.internal.
9+
environment:
10+
- OLLAMA_SERVER=http://host.docker.internal:11434

.devcontainer/setup.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#!/bin/bash
2+
# /.devcontainer/setup.sh
23
set -e # Exit on any error
34

4-
echo "Setting up the Cognosis dev environment..."
5+
echo "Setting up the Demiurge dev environment..."
6+
7+
# Load the correct .env file based on the current branch
8+
BRANCH=$(git rev-parse --abbrev-ref HEAD)
9+
if [[ "$BRANCH" == "staging" ]]; then
10+
cp /config/staging.env .env
11+
elif [[ "$BRANCH" == "main" ]]; then
12+
cp /config/production.env .env
13+
else
14+
cp /config/dev.env .env
15+
fi
516

617
# Install Python dependencies and set up the environment
718
uv install --extra dev
@@ -19,4 +30,4 @@ uv run --with jupyter jupyter lab --ip=0.0.0.0 --port=8888 --allow-root
1930
uv run -m nox -s tests # Runs the tests session defined in the noxfile.py
2031

2132
# Optional: Add any additional setup steps here
22-
echo "Cognosis development environment setup is complete."
33+
echo "Demiurge development environment setup is complete."

.env.example

Whitespace-only changes.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.old/*
44
*.old
55
/nsrc/*
6-
scratch.txt
6+
.env
77

88
# Byte-compiled / optimized / DLL files
99
__pycache__/

__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
import os
2-
from source.utils import __all__ as utils

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "3.8"
2+
3+
services:
4+
app:
5+
build: .
6+
image: open-webui-latest
7+
ports:
8+
- "5000:5000"
9+
network_mode: "host" # Works on Linux; change for Windows
10+
environment:
11+
- OLLAMA_SERVER=http://localhost:11434

src/gg.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import ast
2+
3+
class LambdaModifier(ast.NodeTransformer):
4+
def __init__(self, operation):
5+
self.operation = operation
6+
7+
def visit_Lambda(self, node):
8+
if self.operation == "multiply":
9+
node.body = ast.BinOp(left=node.body, op=ast.Mult(), right=ast.Constant(value=2))
10+
elif self.operation == "subtract":
11+
node.body = ast.BinOp(left=node.body, op=ast.Sub(), right=ast.Constant(value=1))
12+
elif self.operation == "divide":
13+
node.body = ast.BinOp(left=node.body, op=ast.Div(), right=ast.Constant(value=2))
14+
# Add more operations as needed
15+
return node
16+
17+
def transform_lambda(source_code, operation):
18+
tree = ast.parse(source_code, mode='eval')
19+
modifier = LambdaModifier(operation)
20+
modified_tree = modifier.visit(tree)
21+
return ast.unparse(modified_tree)
22+
23+
if __name__ == "__main__":
24+
source_code = "lambda x: x + 2"
25+
for operation in ["multiply", "subtract", "divide"]:
26+
modified_code = transform_lambda(source_code, operation)
27+
print(f"Operation: {operation}, Modified Code: {modified_code}")
28+
29+
source_code = "lambda x: x + 2"
30+
operations = ["multiply", "subtract", "divide"]
31+
32+
for operation in operations:
33+
modified_code = transform_lambda(source_code, operation)
34+
print(f"Operation: {operation}, Modified Code: {modified_code}")

src/pp.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import ast
2+
3+
# Define a lambda function
4+
source_code = "lambda x: x + 2"
5+
6+
# Parse the source code into an AST
7+
tree = ast.parse(source_code, mode='eval')
8+
9+
# Print the AST representation
10+
print(ast.dump(tree, annotate_fields=True))
11+
12+
# Modify the lambda function
13+
class LambdaModifier(ast.NodeTransformer):
14+
def visit_Lambda(self, node):
15+
# Change the body of the lambda function
16+
node.body = ast.BinOp(left=node.body, op=ast.Mult(), right=ast.Constant(value=2))
17+
return node
18+
19+
# Apply the modification
20+
modifier = LambdaModifier()
21+
modified_tree = modifier.visit(tree)
22+
23+
# Convert the AST back to source code using ast.unparse
24+
modified_code = ast.unparse(modified_tree)
25+
print(modified_code)

0 commit comments

Comments
 (0)