Skip to content

Share the node entry point boilerplate - #90

Closed
klangenk wants to merge 1 commit into
share-detector-postprocessingfrom
share-node-entrypoint
Closed

klangenk wants to merge 1 commit into
share-detector-postprocessingfrom
share-node-entrypoint

Conversation

@klangenk

@klangenk klangenk commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Every node's main.py repeats the same twenty lines — read UVICORN_RELOAD, build the settings, construct the node, call uvicorn.run. There are eight copies across the three node repositories, and they have drifted: dfine_node parses settings with configargparse so each one is both a flag and an environment variable, while yolov5_node and classification_node hand-roll os.getenv with asserts and hardcode the host and port.

This puts it in one place, so a new node's entry point is the two lines that are actually its own.

Stacked on #89; review that one first.

Implementation

  • Add helpers/entrypoint.py with node_parser(description=, legacy_env_prefix=) and run_node(app, args)
  • A setting is named after its flag: --conf-threshold reads CONF_THRESHOLD. One declaration yields a flag, an environment variable, and a --help entry.
  • legacy_env_prefix accepts a prefix an earlier version of a node required, with a warning naming the replacement, so adopting this breaks no deployment
  • Add configargparse to the runtime dependencies
  • Nine tests in tests/unit

Why unprefixed names

dfine_node required a DFINE_TRAINER_ / DFINE_DETECTOR_ prefix; the other two read bare names. Bare wins here because yolov5_node is the widely deployed one and dfine_node is still in beta — so the repositories running in the field keep every variable they already set, and the one repository that has to move is the one where moving is cheap. dfine_node passes legacy_env_prefix so its beta deployments keep working meanwhile.

--host and --port are the exception

They read NODE_HOST and NODE_PORT, not the names their flags imply. The bare HOST already means the loop's address — every deployment sets it, face_detection's compose file sets HOST=preview.learning-loop.ai — and a node adopting it would hand that to uvicorn and fail to bind. There is a test asserting exactly this.

Note

logging.basicConfig(...) in the trainers is deliberately not reproduced. helpers/log_conf.py configures the root logger at import, so basicConfig has been returning without doing anything — verified, not assumed.


⬛ claude-opus-5[1m] · 600k tokens · $14.50

Every main.py in every node repository repeats the same twenty lines: read
UVICORN_RELOAD, build the settings, construct the node, call uvicorn.run.
Eight copies across three repositories, and they had drifted - dfine parses
settings with configargparse so each one is both a flag and an environment
variable, while the others hand-roll os.getenv plus asserts and hardcode the
host and port.

node_parser and run_node put that in one place. A setting is named after its
flag: --conf-threshold reads CONF_THRESHOLD. That is what yolov5_node and
classification_node already use, so adopting this renames nothing in the
repositories that are actually deployed.

--host and --port are the exception, reading NODE_HOST and NODE_PORT. The
bare HOST already means the loop's address - every deployment sets it - and a
node adopting that would hand it to uvicorn and fail to bind.

dfine_node required a DFINE_TRAINER_ / DFINE_DETECTOR_ prefix, so it passes
legacy_env_prefix and its prefixed names keep working with a warning naming
the replacement.

The logging.basicConfig call the trainers carry is not reproduced here - the
library configures the root logger on import, so it has been a no-op.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@klangenk
klangenk force-pushed the share-node-entrypoint branch from e1bd034 to fa8505c Compare August 21, 2026 06:42
@klangenk

Copy link
Copy Markdown
Contributor Author

Superseded by #94, which combines all three phases into one PR per repository. The commits are unchanged and still readable in order.

@klangenk klangenk closed this Aug 21, 2026
@klangenk
klangenk deleted the share-node-entrypoint branch August 21, 2026 14:13
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