+
Skip to content

Conversation

PProfizi
Copy link
Contributor

@PProfizi PProfizi commented Feb 21, 2025

Solves #928

PR on PyDPF-Post will make use of new Workflow.safe_connect_with().

Edit: not sure about the naming. Should it rather be Workflow.connect_with_available, or something else? @BClappe

Also I realize that changing the behavior of Workflow.connect_with to now raise if an input or output is unavailable, is a breaking change of a sort. Maybe we should actually keep connect_with as-is or even put the filtering logic there, and create a new method Workflow.connect_with_error which raises in the case of an unavailable input or output. What do you think?

@PProfizi PProfizi added the bug Something isn't working label Feb 21, 2025
@PProfizi PProfizi self-assigned this Feb 21, 2025
@PProfizi PProfizi linked an issue Feb 21, 2025 that may be closed by this pull request
3 tasks
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.58%. Comparing base (05c565c) to head (19b02b1).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2110      +/-   ##
==========================================
- Coverage   86.60%   86.58%   -0.03%     
==========================================
  Files          90       90              
  Lines       10282    10284       +2     
==========================================
- Hits         8905     8904       -1     
- Misses       1377     1380       +3     

out.append(self._api.work_flow_output_by_index(self, i))
return out

def safe_connect_with(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

safe may be misleading, as to me it would mean 'if you use this function, you can be sure that what you asked for has been checked and is valid', not 'I'll only connect what can be and ignore the rest'.

Something like soft_connect_with maybe?

@rafacanton
Copy link
Contributor

@PProfizi To answer the question in the description, the original problem is that before we were crashing in the kernel and not raisin in Python, so in any way the connection with wrong labels was not warking (the process couldn't be run end-to-end). Therefore, why having a new method?

@PProfizi
Copy link
Contributor Author

PProfizi commented Feb 25, 2025

@PProfizi To answer the question in the description, the original problem is that before we were crashing in the kernel and not raisin in Python, so in any way the connection with wrong labels was not warking (the process couldn't be run end-to-end). Therefore, why having a new method?

Because weirdly it did not crash all the time, for example in PyDPF-Post's tests I have to update calls because workflow connections with unavailable inputs or outputs are done all the time, without raising and without crashing.
I think the case where it crashes is a specific case.
Which is why this ends-up being a mix between a bug fix and a breaking change in behavior.

@PProfizi
Copy link
Contributor Author

Just to sum-up:

  • initial reported problem is that Workflow.connect_with() sometimes crashes the server due to unavailable inputs/outputs on either workflow being connected -> instead we should check for that in Python before the server call, and raise an explicit and helpful Python ValueError.
  • This however started raising errors in PyDPF-Post where calls to Workflow.connect_with() which used to work now raise the error, meaning they did not crash the server despite unavailable inputs/outputs -> this means the change is not only a bug fix but also a breaking change for cases where it used to work and may have to be treated as such
  • A solution is to filter the inputs/outputs to connect given to the method, and only perform connections for available ones. This way instead of raising an error we filter and clean the dict for the user -> this is however hidden from the user who may not understand why a connection is not made. Should we then raise a warning? These are going to be raised a lot.
  • This is why another solution is to have two distinct methods: one which filters for the user, and one which raises if something is unavailable. -> we could also add a new option to Workflow.connect_with() which switches between filtering and raising.

@rafacanton
Copy link
Contributor

Just to sum-up:

  • initial reported problem is that Workflow.connect_with() sometimes crashes the server due to unavailable inputs/outputs on either workflow being connected -> instead we should check for that in Python before the server call, and raise an explicit and helpful Python ValueError.
  • This however started raising errors in PyDPF-Post where calls to Workflow.connect_with() which used to work now raise the error, meaning they did not crash the server despite unavailable inputs/outputs -> this means the change is not only a bug fix but also a breaking change for cases where it used to work and may have to be treated as such
  • A solution is to filter the inputs/outputs to connect given to the method, and only perform connections for available ones. This way instead of raising an error we filter and clean the dict for the user -> this is however hidden from the user who may not understand why a connection is not made. Should we then raise a warning? These are going to be raised a lot.
  • This is why another solution is to have two distinct methods: one which filters for the user, and one which raises if something is unavailable. -> we could also add a new option to Workflow.connect_with() which switches between filtering and raising.

Thanks for summarizing everything so clearly. I think that the followed approach (with the 2 methods) is the right one giving all the compatibility restrictions

@PProfizi
Copy link
Contributor Author

PProfizi commented Feb 26, 2025

@rafacanton I ended-up adding the permissive parameter with a default value of True which I think is the graceful way of solving this.
I think most people who will want to use permissive=False are developers and not users.

@PProfizi PProfizi merged commit 87e9799 into master Feb 26, 2025
45 checks passed
@PProfizi PProfizi deleted the fix/raise_on_workflow_connect_with_wrong_label branch February 26, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OSError on wrong output label when connecting two workflows

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载