# Plan 5: Custom Attributes for PsiJ Job Submission

## Objective
Extend the PsiJ submission UI in the Edge Explorer to allow users to specify arbitrary custom attributes (e.g., Slurm resource constraints, GPU types) for their jobs.

## Implementation Steps

### 1. Update PsiJ Template HTML
- **File**: `examples/edge_explorer.html`
- **Action**: Add an "Attributes" section to the PsiJ form.
- **Action**: Include a dynamic table/list where users can add "Key" and "Value" pairs.
- **Action**: Add a "➕ Add Attribute" button.

### 2. Update Submission Logic
- **File**: `examples/edge_explorer.html` (JS)
- **Action**: In `submitPsijJob()`, iterate over the custom attribute rows.
- **Action**: Pack these into the `attributes` dictionary of the `job_spec`.
- **Action**: Ensure special handling for common Slurm attributes like `slurm.constraint` if they need specific formatting.

### 3. Backend Verification
- **File**: `src/radical/edge/plugin_psij.py`
- **Action**: Ensure the `submit_job` endpoint correctly forwards the entire `attributes` dictionary to the underlying `psij.JobSpec`. (This should already work if the dictionary is passed through, but needs validation).

## Test Plan
1. **UI Interactivity**:
    - Open the explorer.
    - Go to PsiJ Jobs.
    - Click "Add Attribute" multiple times.
    - Verify rows can be filled and also removed.
2. **End-to-End Submission**:
    - Add an attribute like `my.custom.attr = test_value`.
    - Submit the job.
    - Check the edge/service logs to verify that the PsiJ job spec received this attribute.
3. **Slurm Constraints**:
    - If on a Slurm system, add `slurm.constraint = "cpu_gen_1"`.
    - Verify that the job is submitted with the correct constraint passed to the batch system.
