Skip to content

Clarify placeholder-editing guidance and add run-timing output - #13

Merged
3 commits merged into
mainfrom
doc-271-clarify-validation-and-timing
Aug 24, 2026
Merged

Clarify placeholder-editing guidance and add run-timing output#13
3 commits merged into
mainfrom
doc-271-clarify-validation-and-timing

Conversation

@monica-unstructured

@monica-unstructured monica-unstructured commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #11 (merged). Adds two independent improvements to both sample scripts:

  • Moved code block were user has to set variables to the top of the script, prior to any validation. This avoids confusion for the user that's updating the script variables.
  • Cleaned up comments from prior line order.

Test plan

  • python3 -m py_compile on both scripts
  • Ran both scripts end-to-end against the live API multiple times; confirmed the printed timing matches wall-clock observation
  • Confirmed both scripts remain byte-identical to the embedded code blocks in docs PR #1090's transform/quickstart-python.mdx, apart from the EXTRACTION_PROMPT/Extractor node difference between the two scripts

🤖 Generated with Claude Code

- Add inline "DO NOT UPDATE" markers on the validate_inputs() checks
  and a bounded "SET THE VARIABLES BELOW" section around the settings
  block, so the block a reader actually edits is visually distinct
  from the validation logic and from the values already preset for
  them (API_URL, EXTRACTION_PROMPT).
- Print a start/end timestamp and elapsed run time after the job
  output is downloaded, so readers can see how long a run actually
  took without needing an external stopwatch.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Shadow auto-approve: would not auto-approve. This PR does not meet the repository auto-approval settings.

Re-trigger cubic

Keep the validate_inputs() clarity comments and the "SET THE VARIABLES
BELOW" section from this PR; drop the start/end timestamp and elapsed
time printing added in the previous commit.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 2 files (changes from recent commits).

Shadow auto-approve: would not auto-approve. This PR does not meet the repository auto-approval settings.

Re-trigger cubic

Move the editable settings block (API_KEY, INPUT_DIR, OUTPUT_DIR)
before validate_inputs(), so a reader hits what they need to edit
before the validation logic. Simplify validate_inputs()'s comments now
that the settings a reader edits sit visually apart from the function
entirely, rather than needing inline markers to distinguish them.
Matches the same restructuring in docs PR #1090's quickstart-python.mdx.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="transform/sample-code/partition-quickstart.py">

<violation number="1" location="transform/sample-code/partition-quickstart.py:30">
P2: The validation checks still contain the same placeholder strings as the editable settings, but removing their `DO NOT UPDATE` markers reintroduces the ambiguity this change is meant to resolve. Keep the marker on each validation check.</violation>
</file>

<file name="transform/sample-code/extract-quickstart.py">

<violation number="1" location="transform/sample-code/extract-quickstart.py:30">
P2: The validation comparisons no longer identify their literals as non-editable, so readers can mistake these guard values for the settings they should change. Restore `# <-- DO NOT UPDATE` on each validation check to preserve the promised placeholder-editing guidance.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.
Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment on lines 30 to 35
if api_key in ("YOUR_API_KEY_HERE", ""):
raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
if input_dir in ("/full/path/to/your/input/directory", ""):
raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.")
if output_dir in ("/full/path/to/your/output/directory", ""):
raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The validation checks still contain the same placeholder strings as the editable settings, but removing their DO NOT UPDATE markers reintroduces the ambiguity this change is meant to resolve. Keep the marker on each validation check.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At transform/sample-code/partition-quickstart.py, line 30:

<comment>The validation checks still contain the same placeholder strings as the editable settings, but removing their `DO NOT UPDATE` markers reintroduces the ambiguity this change is meant to resolve. Keep the marker on each validation check.</comment>

<file context>
@@ -41,6 +25,18 @@ def validate_inputs(api_key, input_dir, output_dir):
 
+# Validate the variable settings
+def validate_inputs(api_key, input_dir, output_dir):
+    if api_key in ("YOUR_API_KEY_HERE", ""):
+        raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
+    if input_dir in ("/full/path/to/your/input/directory", ""):
</file context>
Suggested change
if api_key in ("YOUR_API_KEY_HERE", ""):
raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
if input_dir in ("/full/path/to/your/input/directory", ""):
raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.")
if output_dir in ("/full/path/to/your/output/directory", ""):
raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.")
if api_key in ("YOUR_API_KEY_HERE", ""): # <-- DO NOT UPDATE
raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
if input_dir in ("/full/path/to/your/input/directory", ""): # <-- DO NOT UPDATE
raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.")
if output_dir in ("/full/path/to/your/output/directory", ""): # <-- DO NOT UPDATE
raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.")

Comment on lines 30 to 35
if api_key in ("YOUR_API_KEY_HERE", ""):
raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
if input_dir in ("/full/path/to/your/input/directory", ""):
raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.")
if output_dir in ("/full/path/to/your/output/directory", ""):
raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The validation comparisons no longer identify their literals as non-editable, so readers can mistake these guard values for the settings they should change. Restore # <-- DO NOT UPDATE on each validation check to preserve the promised placeholder-editing guidance.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At transform/sample-code/extract-quickstart.py, line 30:

<comment>The validation comparisons no longer identify their literals as non-editable, so readers can mistake these guard values for the settings they should change. Restore `# <-- DO NOT UPDATE` on each validation check to preserve the promised placeholder-editing guidance.</comment>

<file context>
@@ -39,13 +23,26 @@ def validate_inputs(api_key, input_dir, output_dir):
+
+# Validate the variable settings
+def validate_inputs(api_key, input_dir, output_dir):
+    if api_key in ("YOUR_API_KEY_HERE", ""):
+        raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
+    if input_dir in ("/full/path/to/your/input/directory", ""):
</file context>
Suggested change
if api_key in ("YOUR_API_KEY_HERE", ""):
raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
if input_dir in ("/full/path/to/your/input/directory", ""):
raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.")
if output_dir in ("/full/path/to/your/output/directory", ""):
raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.")
if api_key in ("YOUR_API_KEY_HERE", ""): # <-- DO NOT UPDATE
raise SystemExit("Set API_KEY to your Unstructured API key before running this script.")
if input_dir in ("/full/path/to/your/input/directory", ""): # <-- DO NOT UPDATE
raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.")
if output_dir in ("/full/path/to/your/output/directory", ""): # <-- DO NOT UPDATE
raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.")

@ghost
ghost merged commit 57ac6d2 into main Aug 24, 2026
4 checks passed
@ghost
ghost deleted the doc-271-clarify-validation-and-timing branch August 24, 2026 22:38
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant