harbor run -t openthoughts/tasktrove-exp-rpt-issue-issue-3452harbor download openthoughts/tasktrove-exp-rpt-issue-issue-3452Task: Create a self-contained offline TensorLite-like scaffold in /app/
Summary You need to implement a small, fully self-contained offline workflow that mimics a tiny TensorFlow Lite-like lifecycle. The goal is to have no external network access, and all artifacts are created locally. The deliverables are a set of scripts that generate dummy artifacts, perform a tiny inferences, and verify outputs. The agent should create/modify files under /app/ with executable permissions and ensure deterministic behavior (e.g., fixed inference result 0.42).
Bug/Feature request
Files to create/modify (in /app/)
Before state (current placeholder content you will replace) Note: These blocks show a minimal, non-working placeholder version that does not fulfill the offline scaffold requirements. You will replace with final implementations described below.
#!/usr/bin/env python3
# placeholder before
import sys
def convert():
print("Converting model... (placeholder)")
if __name__ == "__main__":
convert()
#!/usr/bin/env bash
set -e
# placeholder before
echo "Building Android AAR (placeholder) — offline scaffold"
#!/usr/bin/env bash
set -e
# placeholder before
echo "Building iOS Bazel target (placeholder) — offline scaffold"
#!/usr/bin/env python3
# placeholder before
print("Inference result: 0.0")
#!/usr/bin/env bash
set -euo pipefail
echo "Preparing and testing (placeholder)"
#!/usr/bin/env bash
set -euo pipefail
echo "Verifying artifacts (placeholder)"
What to implement (behavioral requirements)
How to run
Acceptance criteria
Inline source blocks to guide implementation The following code blocks show representative final implementations you should create in /app/. They are provided as guidance; you should implement equivalent, working scripts consistent with the described behavior.
#!/usr/bin/env python3
import pathlib
def main():
out_file = pathlib.Path("converted_model.tflite")
# Write a small non-empty dummy content
content = b"dummy tflite content"
out_file.write_bytes(content)
print(f"Wrote {out_file} ({len(content)} bytes)")
if __name__ == "__main__":
main()
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(pwd)"
AAR_DIR="$ROOT_DIR/android/aar/org/tensorflow/tlite"
mkdir -p "$AAR_DIR"
# placeholder.txt
echo "This is a placeholder AAR structure" > "$AAR_DIR/placeholder.txt"
# Tiny mock binary (non-empty)
LIB="$AAR_DIR/libtflite.so"
printf "%s" "MOCK_BINARY" > "$LIB"
chmod 644 "$LIB"
echo "Created Android AAR scaffold at $AAR_DIR"
#!/usr/bin/env bash
set -euo pipefail
FRAMEWORK_DIR="bazel-bin/tensorflow/lite/ios/framework/TensorFlowLite.framework"
mkdir -p "$FRAMEWORK_DIR"
# dummy binary inside framework
echo "MOCK_IOS_BINARY" > "$FRAMEWORK_DIR/TensorFlowLite"
chmod 644 "$FRAMEWORK_DIR/TensorFlowLite"
# simple Info.plist
cat > "$FRAMEWORK_DIR/Info.plist" << 'PLIST'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>TensorFlowLite</string>
<key>CFBundleVersion</key>
<string>0.0.0</string>
</dict>
</plist>
PLIST
echo "Created iOS framework scaffold at $FRAMEWORK_DIR"
#!/usr/bin/env python3
import pathlib
def main():
model_path = pathlib.Path("converted_model.tflite")
if not model_path.is_file() or model_path.stat().st_size == 0:
raise SystemExit("converted_model.tflite is missing or empty")
result = 0.42
print(f"Inference result: {result}")
pathlib.Path("inference.log").write_text(f"Inference result: {result}\n")
if __name__ == "__main__":
main()
#!/usr/bin/env bash
set -euo pipefail
LOG="test.log"
# Clean previous artifacts (best-effort)
rm -f test.log || true
rm -f converted_model.tflite || true
rm -rf android || true
rm -rf bazel-bin || true
rm -f inference.log || true
{
echo "Starting offline self-contained test run..."
python3 convert_model.py
bash build_android_aar.sh
bash build_ios_bazel.sh
python3 run_inference.py
} &> "$LOG"
echo "Test run complete. See $LOG for details."
#!/usr/bin/env bash
set -euo pipefail
errors=0
if [[ ! -f converted_model.tflite || ! -s converted_model.tflite ]]; then
echo "ERROR: converted_model.tflite is missing or empty."
errors=$((errors+1))
fi
if [[ ! -d android/aar/org/tensorflow/tlite/ ]]; then
echo "ERROR: Android AAR scaffold missing at android/aar/org/tensorflow/tlite/."
errors=$((errors+1))
else
if [[ ! -f android/aar/org/tensorflow/tlite/placeholder.txt || ! -s android/aar/org/tensorflow/tlite/placeholder.txt ]]; then
echo "ERROR: android/aar/org/tensorflow/tlite/placeholder.txt missing or empty."
errors=$((errors+1))
fi
if [[ ! -f android/aar/org/tensorflow/tlite/libtflite.so || ! -s android/aar/org/tensorflow/tlite/libtflite.so ]]; then
echo "ERROR: android/aar/org/tensorflow/tlite/libtflite.so missing or empty."
errors=$((errors+1))
fi
fi
if [[ ! -d bazel-bin/tensorflow/lite/ios/framework/TensorFlowLite.framework/ ]]; then
echo "ERROR: iOS framework scaffold missing."
errors=$((errors+1))
else
if [[ ! -f bazel-bin/tensorflow/lite/framework/TensorFlowLite.framework/Info.plist ]]; then
echo "ERROR: Info.plist missing in iOS framework."
errors=$((errors+1))
fi
fi
if [[ ! -f inference.log ]]; then
echo "ERROR: inference.log missing."
errors=$((errors+1))
else
if ! grep -q 'Inference result: 0.42' inference.log; then
echo "ERROR: inference.log does not contain the expected result."
errors=$((errors+1))
fi
fi
if [[ $errors -eq 0 ]]; then
echo "Verification successful: all artifacts present and valid."
else
echo "Verification failed with $errors error(s)."
exit 1
fi
Notes
This task is ready to implement in /app/. After implementing, you can run:
If everything is correct, verify.sh should report a success and you should see the expected Inference result in inference.log as "Inference result: 0.42".