vatlab / sos

SoS workflow system for daily data analysis
http://vatlab.github.io/sos-docs
BSD 3-Clause "New" or "Revised" License
269 stars 45 forks source link

SoS is broken on Python 3.12? #1542

Closed gaow closed 3 months ago

gaow commented 3 months ago

On Python 3.10 and SoS 0.25.0 this workflow:

[1]
parameter: dat = path
input: dat
print(_input)

it works well.

sos run test.sos --dat test.sos
INFO: Running 1:
test.sos
INFO: 1 is completed.
INFO: Workflow default (ID=wadc76383948ec2d8) is executed successfully with 1 completed step.

But on Python 3.12, it fails:

# sos run test.sos --dat test.sos
INFO: Running 1: 
ERROR: [1]: [1]: Failed to process input statement dat
: file_target object has no attribute traced

I have another workflow that shows a different error:

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/.pixi/envs/sos/lib/python3.12/site-packages/sos/targets.py", line 128, in __getattr__
    return self._dict[name]
           ^^^^^^^^^^
  File "/root/.pixi/envs/sos/lib/python3.12/site-packages/sos/targets.py", line 132, in __getattr__
    raise AttributeError(f"{self.__class__.__name__} object has no attribute {name}") from e
AttributeError: file_target object has no attribute _dict

after we upgrade from Python 3.10 to 3.12 it seems we are crippled ..

BoPeng commented 3 months ago

I can reproduce the problem with a Python 3.12 environment, but cannot figure out what went wrong immediately.

I have updated the test suite to add python 3.12 to catch all such problems.

BoPeng commented 3 months ago

ok, find the source of the problem. What we did was sending a compiled global statement in task file to be executed on remote host. However, the docker side uses python 3.10, and the test side uses 3.9, and a change in the ast package has changed the format of the ast object....

$ ssh -q root@localhost -p 32768 "bash --login -c '  sos execute t5ee683a10ef0f203 -v 4 -s force -m run'"
INFO: t5ee683a10ef0f203 started
  File "/usr/local/lib/python3.10/site-packages/sos/__main__.py", line 2831, in main
    args.func(args, workflow_args)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/sos/__main__.py", line 2831, in main
    args.func(args, workflow_args)
  File "/usr/local/lib/python3.10/site-packages/sos/__main__.py", line 1521, in cmd_execute
    exit_code.append(executor.execute(task))
  File "/usr/local/lib/python3.10/site-packages/sos/task_executor.py", line 95, in execute
    res = self.execute_single_task(task_id, params, runtime, sig_content)
  File "/usr/local/lib/python3.10/site-packages/sos/task_executor.py", line 146, in execute_single_task
    prepare_env(global_def[0], global_def[1])
  File "/usr/local/lib/python3.10/site-packages/sos/executor_utils.py", line 210, in prepare_env
    exec(compile(gdef, filename="<ast>", mode="exec"), env.sos_dict._dict)
TypeError: required field "lineno" missing from alias

So the problem happens if local and remote sos has different versions of python, which we can fix, or ignore.

gaow commented 3 months ago

Ahh .... I think it is enough to check and report error or warning for that case, leaving it for users to fix. That should be fair enough.

BoPeng commented 3 months ago

sos 0.25.1 is released for this fix.

gaow commented 3 months ago

great thanks @BoPeng , i take that conda release is automatic and will be there in a few hours? Sorry i cannot remember if it is automatic or you have to click on some extra buttons. I'll merge the PR once I see it pass on conda-forge GitHub.

BoPeng commented 3 months ago

automatic, merged.