def single_account_standard_job()

in src/run.py [0:0]


def single_account_standard_job() -> int:
    # in case it's a standard job , tenant_name will always exist
    tenant_name = cast(str, BSP.env.tenant_name())
    tenant = cast(Tenant, SP.modular_client.tenant_service().get(tenant_name))

    if job_id := BSP.env.job_id():
        # custodian job id, present only for standard jobs
        job = cast(Job, SP.job_service.get_nullable(job_id))
        if BSP.env.is_docker():
            updater = JobUpdater(job)
        else:
            updater = NullJobUpdater(job)  # updated in caas-job-updater
    else:  # scheduled job, generating it dynamically
        scheduled = ScheduledJob.get_nullable(BSP.env.scheduled_job_name())
        updater = JobUpdater.from_batch_env(
            environment=dict(os.environ),
            rulesets=scheduled.context.scan_rulesets
        )
        updater.save()
        job = updater.job
        BSP.env.override_environment({BatchJobEnv.CUSTODIAN_JOB_ID.value: job.id})

    if BSP.env.is_scheduled():  # locking scanned regions
        TenantSettingJobLock(tenant_name).acquire(
            job_id=job.id,
            regions=BSP.env.target_regions() or {GLOBAL_REGION}
        )
        update_scheduled_job()

    updater.created_at = utc_iso()
    updater.started_at = utc_iso()
    updater.status = JobState.RUNNING
    updater.update()

    temp_dir = tempfile.TemporaryDirectory()

    try:
        standard_job(job, tenant, Path(temp_dir.name))
        updater.status = JobState.SUCCEEDED
        updater.stopped_at = utc_iso()
        code = 0
    except ExecutorException as e:
        _LOG.exception(f'Executor exception {e.error} occurred')
        # in case the job has failed, we should update it here even if it's
        # saas installation because we cannot retrieve traceback from
        # caas-job-updater lambda
        updater = JobUpdater.from_job_id(job.id)
        updater.status = JobState.FAILED
        updater.stopped_at = utc_iso()
        updater.reason = e.error.with_reason()
        match e.error:
            case ExecutorError.LM_DID_NOT_ALLOW:
                code = 2
            case _:
                code = 1
    except Exception:
        _LOG.exception('Unexpected error occurred')
        updater = JobUpdater.from_job_id(job.id)
        updater.status = JobState.FAILED
        updater.stopped_at = utc_iso()
        updater.reason = ExecutorError.INTERNAL
        code = 1
    finally:
        Path(CACHE_FILE).unlink(missing_ok=True)
        TenantSettingJobLock(tenant_name).release(job.id)
        temp_dir.cleanup()

    updater.update()

    if BSP.env.is_docker() and BSP.env.is_licensed_job():
        _LOG.info('The job is licensed on premises. Updating in LM')
        SP.license_manager_service.cl.update_job(
            job_id=job.id,
            customer=job.customer_name,
            created_at=job.created_at,
            started_at=job.started_at,
            stopped_at=job.stopped_at,
            status=job.status
        )
    return code