qcc_kplugin.simrun ================== .. py:module:: qcc_kplugin.simrun .. autoapi-nested-parse:: A ``qcc sim auto`` run that outlives KLayout (plain Python, no pya: unit-tested outside KLayout). Simulate starts the run *detached* (own process group, no console window, breaking away from a job object that would end it with KLayout), with its output in ``.flow/sim_run.log``. ``.flow/sim_run.json`` is the run record: pid, start time, arguments, the log and the status file ``qcc`` writes, and the state. When the design is opened again (or KLayout restarts with it) :func:`flow.resume_runs` reads the record: a run that ended meanwhile is imported (its results are already in the design's run state; ``qcc`` also saved them as ``build//__results.json``), a run still going is watched and imported when it ends. Attributes ---------- .. autoapisummary:: qcc_kplugin.simrun.CREATE_BREAKAWAY_FROM_JOB qcc_kplugin.simrun.CREATE_NEW_PROCESS_GROUP qcc_kplugin.simrun.CREATE_NO_WINDOW qcc_kplugin.simrun.LOG qcc_kplugin.simrun.RECORD qcc_kplugin.simrun.STILL_ACTIVE Classes ------- .. autoapisummary:: qcc_kplugin.simrun.PidProc Functions --------- .. autoapisummary:: qcc_kplugin.simrun.launch qcc_kplugin.simrun.outcome qcc_kplugin.simrun.pid_alive qcc_kplugin.simrun.read_record qcc_kplugin.simrun.record_path qcc_kplugin.simrun.write_record Module Contents --------------- .. py:class:: PidProc(rec: dict) The ``Popen`` look-alike of a run this KLayout did not start (``poll`` / ``pid`` / ``terminate``). .. py:method:: poll() .. py:method:: terminate() .. py:method:: wait(timeout=None) .. py:attribute:: pid .. py:attribute:: rec .. py:attribute:: returncode :value: None .. py:function:: launch(cmd, cwd, env, log_path) -> subprocess.Popen Start ``cmd`` detached from this process: it keeps running when KLayout quits. Output goes to ``log_path``. .. py:function:: outcome(rec: dict) -> str ``running`` while the process lives, else ``done`` / ``failed`` / ``cancelled`` from what ``qcc`` wrote (its status file, else the log's "done in" line); a process that vanished without either is ``failed``. .. py:function:: pid_alive(pid: int) -> bool .. py:function:: read_record(flow_dir) -> dict | None .. py:function:: record_path(flow_dir) -> pathlib.Path .. py:function:: write_record(flow_dir, rec: dict) -> None .. py:data:: CREATE_BREAKAWAY_FROM_JOB :value: 16777216 .. py:data:: CREATE_NEW_PROCESS_GROUP :value: 512 .. py:data:: CREATE_NO_WINDOW :value: 134217728 .. py:data:: LOG :value: 'sim_run.log' .. py:data:: RECORD :value: 'sim_run.json' .. py:data:: STILL_ACTIVE :value: 259