Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes in git commit and gitignore #272

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import inspect
import shutil
import json
from datetime import datetime
from computations import compute

def datetime_converter(o):
"""Convert datetime objects to string."""
if isinstance(o, datetime):
return o.__str__()

def main():
original_path = os.getcwd()

Expand Down Expand Up @@ -33,28 +39,28 @@ def main():
for key in inspect.signature(compute).parameters.keys():
value = os.getenv(key)
debug_inputs[key] = value

print("debug|||", debug_inputs)

for key in inspect.signature(compute).parameters.keys():
value = os.getenv(key)
debug_inputs[key] = value
params.append(ast.literal_eval(value))
inputs[key] = value

json_inputs = json.dumps(inputs)
print("inputs|||", json_inputs)

outputs = compute(*params)

# the "|||" are used for parsing
json_outputs = json.dumps(outputs)
json_outputs = json.dumps(outputs, default=datetime_converter)
print("outputs|||", json_outputs)

os.chdir(original_path)
for key, value in outputs.items():
with open(block_id + "-" + key + ".txt", "w") as file:
file.write(json.dumps(value))
file.write(json.dumps(value, default=datetime_converter))

# Check the current execution directory for files and folders after the compute function executes
current_files_and_folders = set(os.listdir())
Expand Down
22 changes: 16 additions & 6 deletions frontend/server/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@ import { cacheJoin } from "./cache.js";

async function ensureGitignore(dir) {
const gitignorePath = path.join(dir, ".gitignore");
const ignoreItems = ["history/", "chatHistory.json"];

try {
// Check if .gitignore exists
await fs.promises.access(gitignorePath);
const content = await fs.promises.readFile(gitignorePath, "utf8");
if (!content.includes("history/")) {
await fs.promises.appendFile(gitignorePath, "\nhistory/\n");
return true; // indicates .gitignore was modified

let modified = false;
for (const item of ignoreItems) {
if (!content.includes(item)) {
await fs.promises.appendFile(gitignorePath, `\n${item}\n`);
modified = true;
}
}
return false; // indicates no changes were needed
return modified; // true if any changes were made, false if none needed
} catch (e) {
// .gitignore doesn't exist, create it
await fs.promises.writeFile(gitignorePath, "history/\n", "utf8");
// .gitignore doesn't exist, create it with all items
await fs.promises.writeFile(
gitignorePath,
ignoreItems.join("\n") + "\n",
"utf8",
);
return true; // indicates .gitignore was created
}
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/server/pipelineSerialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export async function copyPipeline(pipelineSpecs, fromDir, toDir) {
const fromBlockIndex = await getBlockIndex([bufferPath]);

if (!(await fileExists(writePipelineDirectory))) {
await fs.mkdir(writePipelineDirectory, { recursive: true });
try {
await fs.mkdir(writePipelineDirectory, { recursive: true });
} catch (error) {
console.log(`Directory ${writePipelineDirectory} already exists`);
}
}

// Gets pipeline specs from the specs coming from the graph
Expand Down
37 changes: 25 additions & 12 deletions frontend/src/components/ZetaneDrawflowEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1018,26 +1018,39 @@ export default class Drawflow {
inputElement = nodeRefs[`${input_id}-input-${input_class}`];
outputElement = nodeRefs[`${output_id}-output-${output_class}`];

if (!inputElement) {
console.error(
`Input element ${input_id}-input-${input_class} not found`,
);
return;
}
if (!outputElement) {
console.error(
`Output element ${output_id}-output-${output_class} not found`,
);
return;
}

const eX =
inputElement.offsetWidth / 2 +
(inputElement.getBoundingClientRect().x -
precanvas.getBoundingClientRect().x) *
inputElement?.offsetWidth / 2 +
(inputElement.getBoundingClientRect()?.x -
precanvas.getBoundingClientRect()?.x) *
precanvasWitdhZoom;
const eY =
inputElement.offsetHeight / 2 +
(inputElement.getBoundingClientRect().y -
precanvas.getBoundingClientRect().y) *
inputElement?.offsetHeight / 2 +
(inputElement.getBoundingClientRect()?.y -
precanvas.getBoundingClientRect()?.y) *
precanvasHeightZoom;

line_x =
outputElement.offsetWidth / 2 +
(outputElement.getBoundingClientRect().x -
precanvas.getBoundingClientRect().x) *
outputElement?.offsetWidth / 2 +
(outputElement.getBoundingClientRect()?.x -
precanvas.getBoundingClientRect()?.x) *
precanvasWitdhZoom;
line_y =
outputElement.offsetHeight / 2 +
(outputElement.getBoundingClientRect().y -
precanvas.getBoundingClientRect().y) *
outputElement?.offsetHeight / 2 +
(outputElement.getBoundingClientRect()?.y -
precanvas.getBoundingClientRect()?.y) *
precanvasHeightZoom;

var x = eX;
Expand Down
Loading