Skip to content

Commit

Permalink
feature: detector / trainer
Browse files Browse the repository at this point in the history
allow to overwrite backdoor controls by env variable
  • Loading branch information
denniswittich committed Oct 1, 2024
1 parent e8bad2e commit 5bcdf36
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ To start a node you have to implement the logic by inheriting from the correspon

You can configure connection to our Learning Loop by specifying the following environment variables before starting:

| Name | Alias | Purpose | Required by |
| ------------------------ | ------------ | ------------------------------------------------------------ | -------------------- |
| LOOP_HOST | HOST | Learning Loop address (e.g. learning-loop.ai) | all |
| LOOP_USERNAME | USERNAME | Learning Loop user name | all besides Detector |
| LOOP_PASSWORD | PASSWORD | Learning Loop password | all besides Detector |
| LOOP_SSL_CERT_PATH | - | Path to the SSL certificate | all (opt.) |
| LOOP_ORGANIZATION | ORGANIZATION | Organization name | Detector |
| LOOP_PROJECT | PROJECT | Project name | Detector |
| MIN_UNCERTAIN_THRESHOLD | PROJECT | smallest confidence (float) at which auto-upload will happen | Detector |
| MAX_UNCERTAIN_THRESHOLD | PROJECT | largest confidence (float) at which auto-upload will happen | Detector |
| INFERENCE_BATCH_SIZE | - | Batch size of trainer when calculating detections | Trainer (opt.) |
| RESTART_AFTER_TRAINING | - | Restart the trainer after training (set to 1) | Trainer (opt.) |
| KEEP_OLD_TRAININGS | - | Do not delete old trainings (set to 1) | Trainer (opt.) |
| TRAINER_IDLE_TIMEOUT_SEC | - | Automatically shutdown trainer after timeout (in seconds) | Trainer (opt.) |
| Name | Alias | Purpose | Required by |
| ------------------------ | ------------ | ------------------------------------------------------------ | ------------------------- |
| LOOP_HOST | HOST | Learning Loop address (e.g. learning-loop.ai) | all |
| LOOP_USERNAME | USERNAME | Learning Loop user name | all besides Detector |
| LOOP_PASSWORD | PASSWORD | Learning Loop password | all besides Detector |
| LOOP_SSL_CERT_PATH | - | Path to the SSL certificate | all (opt.) |
| LOOP_ORGANIZATION | ORGANIZATION | Organization name | Detector |
| LOOP_PROJECT | PROJECT | Project name | Detector |
| MIN_UNCERTAIN_THRESHOLD | PROJECT | smallest confidence (float) at which auto-upload will happen | Detector |
| MAX_UNCERTAIN_THRESHOLD | PROJECT | largest confidence (float) at which auto-upload will happen | Detector |
| INFERENCE_BATCH_SIZE | - | Batch size of trainer when calculating detections | Trainer (opt.) |
| RESTART_AFTER_TRAINING | - | Restart the trainer after training (set to 1) | Trainer (opt.) |
| KEEP_OLD_TRAININGS | - | Do not delete old trainings (set to 1) | Trainer (opt.) |
| TRAINER_IDLE_TIMEOUT_SEC | - | Automatically shutdown trainer after timeout (in seconds) | Trainer (opt.) |
| USE_BACKDOOR_CONTROLS | - | Enable backdoor controls (set to 1) | Trainer / Detector (opt.) |

#### Testing

Expand Down
2 changes: 1 addition & 1 deletion learning_loop_node/detector/detector_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, name: str, detector: DetectorLogic, uuid: Optional[str] = Non
self.include_router(rest_outbox_mode.router, tags=["outbox_mode"])
self.include_router(rest_version_control.router, tags=["model_version"])

if use_backdoor_controls:
if use_backdoor_controls or os.environ.get('USE_BACKDOOR_CONTROLS', '0').lower() in ('1', 'true'):
self.include_router(backdoor_controls.router)

self.setup_sio_server()
Expand Down
2 changes: 1 addition & 1 deletion learning_loop_node/trainer/trainer_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, name: str, trainer_logic: TrainerLogicGeneric, uuid: Optional
self.log.info(
f'Trainer started with an idle_timeout of {self.idle_timeout} seconds. Note that shutdown does not work if docker container has the restart policy set to always')

if use_backdoor_controls:
if use_backdoor_controls or os.environ.get('USE_BACKDOOR_CONTROLS', '0').lower() in ('1', 'true'):
self.include_router(backdoor_controls.router, tags=["controls"])

# ----------------------------------- NODE LIVECYCLE METHODS --------------------------
Expand Down

0 comments on commit 5bcdf36

Please sign in to comment.