Skip to content

Commit

Permalink
cool
Browse files Browse the repository at this point in the history
  • Loading branch information
adnan wahab committed Oct 22, 2024
1 parent e0acb4f commit 0787d44
Show file tree
Hide file tree
Showing 11 changed files with 582 additions and 200 deletions.
176 changes: 173 additions & 3 deletions 200k_prs/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,174 @@

dustynv/jetson-containers
observablheq/runtime
livekit/client-sdk-js

https://github.com/dustynv/jetson-containers
https://github.com/observablheq/runtime
https://github.com/livekit/client-sdk-js
https://github.com/bazelbuild/bazel



[
{
"name": "GoLang",
"repo": "https://github.com/golang/go",
"dependencies": [
{
"name": "gc (Go compiler)",
"description": "Go compiler toolchain"
},
{
"name": "gccgo",
"description": "Alternative Go compiler based on GCC"
},
{
"name": "cmd/compile",
"description": "Go compiler internal package with SSA and IR components"
},
{
"name": "CGO",
"description": "Allows Go programs to call C code"
},
{
"name": "Go Runtime",
"description": "Includes garbage collection, goroutines, and channels"
}
]
},
{
"name": "Node.js",
"repo": "https://github.com/nodejs/node",
"dependencies": [
{
"name": "V8 Engine",
"description": "JavaScript engine by Google"
},
{
"name": "libuv",
"description": "Provides event loop and asynchronous I/O"
},
{
"name": "c-ares",
"description": "A C library for asynchronous DNS requests"
},
{
"name": "OpenSSL",
"description": "Handles TLS and cryptographic operations"
},
{
"name": "HTTP Parser",
"description": "Parses HTTP requests and responses"
},
{
"name": "zlib",
"description": "Handles data compression"
}
]
},
{
"name": "Docker",
"repo": "https://github.com/moby/moby",
"dependencies": [
{
"name": "runc",
"description": "CLI tool for running containers"
},
{
"name": "containerd",
"description": "Manages container lifecycle"
},
{
"name": "libnetwork",
"description": "Provides container networking"
},
{
"name": "BuildKit",
"description": "Optimizes Docker build process"
},
{
"name": "aufs and overlayfs",
"description": "Filesystems for container storage"
}
]
},
{
"name": "Kubernetes",
"repo": "https://github.com/kubernetes/kubernetes",
"dependencies": [
{
"name": "etcd",
"description": "Distributed key-value store for cluster data"
},
{
"name": "containerd",
"description": "Manages containers in Kubernetes"
},
{
"name": "CoreDNS",
"description": "DNS for Kubernetes services"
},
{
"name": "cAdvisor",
"description": "Monitors container resource usage"
},
{
"name": "Flannel or Calico",
"description": "Networking plugins for pod networking"
}
]
},
{
"name": "Slurm",
"repo": "https://github.com/SchedMD/slurm",
"dependencies": [
{
"name": "MySQL or MariaDB",
"description": "Database for job and cluster data"
},
{
"name": "PMIx",
"description": "Process management standard"
},
{
"name": "Munge",
"description": "Authentication system for users and hosts"
},
{
"name": "hwloc",
"description": "Manages hardware topology"
}
]
},
{
"name": "Java (OpenJDK)",
"repo": "https://github.com/openjdk/jdk",
"dependencies": [
{
"name": "JVM",
"description": "Java Virtual Machine for running Java applications"
},
{
"name": "javac",
"description": "Java compiler"
},
{
"name": "JRE libraries",
"description": "Standard libraries for utilities, networking, and I/O"
},
{
"name": "HotSpot",
"description": "Default JVM for memory management and garbage collection"
}
]
}
]
https://github.com/scverse/scanpy


pytorch or tinygrad

//this is the list of deps to sort by prtioity
{
"pytorch": [],
"tinygrad": [],

}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "dependencies": { "ollama": "^0.5.9" } }
12 changes: 12 additions & 0 deletions scripts/_bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@

op item list --vault=personal --tags=api --format json



alias pull="git pull"
alias commit="git add . && git commit -am 'simplify' && git push origin main"
alias status="git status"

# Adding alias to bashrc for best practices
# echo "alias ll='ls -l'" >> ~/.bashrc
# echo "alias la='ls -a'" >> ~/.bashrc
# echo "alias ll='ls -l'" >> ~/.bashrc
# echo "alias grep='grep --color=auto'" >> ~/.bashrc

# Symlink each category into a data folder in the root of this git repo
#chmod +x scripts/*
# ln -s ~/derp/actions ~/homelab_status_page/data/actions
Expand Down
198 changes: 198 additions & 0 deletions scripts/code_base_indexing_for_prediction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
//# zoox is a list of modules - make a comprehension to map filter into a json
import { Ollama } from 'ollama'


//ffi -- - learn p -> js

const read_location = `/home/adnan/derp/ro/mini_zoox/`
import { fstat } from 'fs';
// Import necessary modules
import { readdir, stat, readFile, mkdir } from 'fs/promises';
import path from 'path';

// Configuration
const ROOT_DIR = read_location
const OUTPUT_DIR = '/home/adnan/derp/ro';

// Utility function to get all files recursively
async function getAllFiles(dirPath, arrayOfFiles) {
const files = await readdir(dirPath);

for (const file of files) {
const fullPath = path.join(dirPath, file);
const fileStat = await stat(fullPath);

if (fileStat.isDirectory()) {
await getAllFiles(fullPath, arrayOfFiles);
} else {
arrayOfFiles.push(fullPath);
}
}

return arrayOfFiles;
}

// Task 1: Generate stats about all files
async function generateFileStats(files) {
const fileStats = [];

for (const file of files) {
const fileContent = await readFile(file, 'utf-8');
const fileStat = await stat(file);
const lines = fileContent.split('\n').length;

fileStats.push({
path: file,
size: fileStat.size,
lines: lines,
extension: path.extname(file),
modifiedDate: fileStat.mtime,
});
}

return fileStats;
}

// Task 2: Find dependencies of each file
async function findDependencies(files) {
const dependencies = {};

for (const file of files) {
const fileContent = await readFile(file, 'utf-8');
const importRegex = /import .* from ['"](.*)['"];?/g;
const requireRegex = /require\(['"](.*)['"]\)/g;
const deps = [];
let match;

while ((match = importRegex.exec(fileContent)) !== null) {
deps.push(match[1]);
}

while ((match = requireRegex.exec(fileContent)) !== null) {
deps.push(match[1]);
}

dependencies[file] = deps;
}

return dependencies;
}

// Task 3: Extract all notes (comments)
async function extractComments(files) {
const comments = {};

for (const file of files) {
const fileContent = await readFile(file, 'utf-8');
const commentRegex = /\/\/(.*)|\/\*([\s\S]*?)\*\//g;
const fileComments = [];
let match;

while ((match = commentRegex.exec(fileContent)) !== null) {
fileComments.push(match[1] || match[2]);
}

comments[file] = fileComments;
}

return comments;
}

// Task 4: Count how many files depend on each file
function countReverseDependencies(dependencies) {
const reverseDeps = {};

for (const [file, deps] of Object.entries(dependencies)) {
for (const dep of deps) {
if (!reverseDeps[dep]) {
reverseDeps[dep] = [];
}
reverseDeps[dep].push(file);
}
}

const dependencyCount = {};

for (const [file, dependents] of Object.entries(reverseDeps)) {
dependencyCount[file] = dependents.length;
}

return dependencyCount;
}



async function code_base_indexing_for_prediction() {
// Ensure the output directory exists
await mkdir(OUTPUT_DIR, { recursive: true }); // Create the directory if it doesn't exist

// Step 1: Get all files
const allFiles = await getAllFiles(ROOT_DIR, []);

// Task 1
const stats = await generateFileStats(allFiles);
await Bun.write(`${OUTPUT_DIR}/fileStats.json`, JSON.stringify(stats, null, 2));

// Task 2
const dependencies = await findDependencies(allFiles);
await Bun.write(`${OUTPUT_DIR}/dependencies.json`, JSON.stringify(dependencies, null, 2));

// Task 3
const notes = await extractComments(allFiles);
await Bun.write(`${OUTPUT_DIR}/notes.json`, JSON.stringify(notes, null, 2));

// Task 4
const reverseDependencyCount = countReverseDependencies(dependencies);
await Bun.write(`${OUTPUT_DIR}/reverseDependencies.json`, JSON.stringify(reverseDependencyCount, null, 2));

console.log('All tasks completed successfully!');
}


// Execute the main function


// code_base_indexing_for_prediction().catch((error) => {
// console.error('An error occurred:', error);
// });


// Main function to run all tasks
let view_location = `https://files.hashirama.blog/derp/intermediate_representation/micro_zoox/index.json`





async function robot_lamma () {

const stats = await Bun.file(`${OUTPUT_DIR}/fileStats.json`).json();
const dependencies = await Bun.file(`${OUTPUT_DIR}/dependencies.json`).json();
const notes = await Bun.file(`${OUTPUT_DIR}/notes.json`).json();

const file_names = Object.keys(dependencies);

console.log(file_names.length)


const ollama = new Ollama({ host: 'http://127.0.0.1:11434' })

//ollama_client
const message = {
role: "user",
content: "what does this file mean?"
}
file_names.slice(0, 20).map(async (file_name) => {
const file_content = await Bun.file(file_name).text()
const response = await ollama.chat({
model: 'llama3.2',
input: file_content,
messages: [message]
})
})

//const reverseDependencyCount = await Bun.file(`${OUTPUT_DIR}/reverseDependencies.json`).json(); -- too long
}
console.time("code_base_indexing_for_prediction");
robot_lamma()
console.timeEnd("code_base_indexing_for_prediction")
Loading

0 comments on commit 0787d44

Please sign in to comment.