I'm trying to submit another experiment using the virtual device scheduler.

This is my schedule experiment.

from artiq.experiment import *

class ScheduleTest(EnvExperiment):
    def build(self):
        self._scheduler = self.get_device("scheduler")

    def run(self):
        new_expid = {
            "file": "repository/test.py",
            "class_name": "Test",
            "arguments": {},
            "log_level": 30,
        }

        self._scheduler.submit(pipeline_name="main", expid=new_expid)

This is the content of test.py and I can submit it successfully.

from artiq.experiment import *

class Test(EnvExperiment):
    def build(self):
        self.setattr_device("core")

    def run(self):
        print("test")

However, if test.py has code running on kernel, the submission will fail.

from artiq.experiment import *

class Test(EnvExperiment):
    def build(self):
        self.setattr_device("core")

    def run(self):
        print("test")
        self._run()

    @kernel
    def _run(self):
        pass

This is the error message.

root:Terminating with exception (OSError: source code not available)
Traceback (most recent call last):
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/master/worker_impl.py", line 346, in main
    exp_inst.run()
  File "repository/test.py", line 9, in run
    self._run()
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/language/core.py", line 54, in run_on_core
    return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/core.py", line 139, in run
    self.compile(function, args, kwargs, set_result)
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/core.py", line 107, in compile
    stitcher.stitch_call(function, args, kwargs, set_result)
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/compiler/embedding.py", line 777, in stitch_call
    call_node = synthesizer.call(function, args, kwargs, callback)
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/compiler/embedding.py", line 448, in call
    callee_node = self.quote(callee)
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/compiler/embedding.py", line 342, in quote
    function_type = self.quote_function(value, self.expanded_from)
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/compiler/embedding.py", line 1208, in _quote_function
    self._quote_embedded_function(function,
  File "/nix/store/4zcbbhy7n67ymgm1qs8cmx353iy0r8l2-python3-3.9.13-env/lib/python3.9/site-packages/artiq/compiler/embedding.py", line 955, in _quote_embedded_function
    source_code = inspect.getsource(embedded_function)
  File "/nix/store/65h1mb8604dbw077762j702q6b8i0mpw-python3-3.9.13/lib/python3.9/inspect.py", line 1024, in getsource
    lines, lnum = getsourcelines(object)
  File "/nix/store/65h1mb8604dbw077762j702q6b8i0mpw-python3-3.9.13/lib/python3.9/inspect.py", line 1006, in getsourcelines
    lines, lnum = findsource(object)
  File "/nix/store/65h1mb8604dbw077762j702q6b8i0mpw-python3-3.9.13/lib/python3.9/inspect.py", line 827, in findsource
    raise OSError('source code not available')
OSError: source code not available

How can I fix it?

    Hi qllopg, this certainly looks like a bug. I got the same result on the latest master and opened an issue: 2021 . Thank you for reporting it!

      esavkin I solved this problem by changing the path "file": "repository/test.py" to absolute path.

        qllopg Well, that's still looks like a bug and to be fixed.