Improve exception handling from worker#182
Open
paoloalba wants to merge 2 commits intonalepae:masterfrom
Open
Conversation
|
The error message could be improved but it's definitely a good option to have. |
Codecov Report
@@ Coverage Diff @@
## master #182 +/- ##
===========================================
- Coverage 91.37% 79.59% -11.79%
===========================================
Files 12 12
Lines 580 588 +8
===========================================
- Hits 530 468 -62
- Misses 50 120 +70
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Owner
|
Hi @ichoyjx : When trying the following code, the df_size = int(5e6)
df = pd.DataFrame(dict(a=np.random.randint(1, 8, df_size),
b=np.random.rand(df_size)))
def func(x):
if x.a == 5:
raise RuntimeError("Bonjour")
return math.sin(x.a**2) + math.sin(x.b**2)
res = df.apply(func, axis=1) # OK (RuntimeError Bonjour is raised)
res_parallel = df.parallel_apply(func, axis=1) # NOKThe stacktrace is: ---------------------------------------------------------------------------
TraitError Traceback (most recent call last)
File <timed exec>:1, in <module>
File ~/Perso/pandarallel/pandarallel/core.py:447, in parallelize_with_pipe.<locals>.closure(data, user_defined_function, *user_defined_function_args, **user_defined_function_kwargs)
445 progress_bars.update(progresses)
446 elif worker_status == WorkerStatus.Error:
--> 447 progress_bars.set_error(worker_index, payload)
449 results = results_promise.get()
451 return data_type.reduce(results, reduce_extra)
File ~/Perso/pandarallel/pandarallel/progress_bars.py:180, in ProgressBarsNotebookLab.set_error(self, index, err_msg)
178 bar, _, txt_area = self.__bars[index].children
179 bar.bar_style = "danger"
--> 180 txt_area.value = err_msg
181 txt_area.layout.display = ""
File ~/.pyenv/versions/3.10.5/envs/pandarallel/lib/python3.10/site-packages/traitlets/traitlets.py:715, in TraitType.__set__(self, obj, value)
713 raise TraitError('The "%s" trait is read-only.' % self.name)
714 else:
--> 715 self.set(obj, value)
File ~/.pyenv/versions/3.10.5/envs/pandarallel/lib/python3.10/site-packages/traitlets/traitlets.py:689, in TraitType.set(self, obj, value)
688 def set(self, obj, value):
--> 689 new_value = self._validate(obj, value)
690 try:
691 old_value = obj._trait_values[self.name]
File ~/.pyenv/versions/3.10.5/envs/pandarallel/lib/python3.10/site-packages/traitlets/traitlets.py:721, in TraitType._validate(self, obj, value)
719 return value
720 if hasattr(self, "validate"):
--> 721 value = self.validate(obj, value) # type:ignore[attr-defined]
722 if obj._cross_validation_lock is False:
723 value = self._cross_validate(obj, value)
File ~/.pyenv/versions/3.10.5/envs/pandarallel/lib/python3.10/site-packages/traitlets/traitlets.py:2380, in Unicode.validate(self, obj, value)
2378 msg = "Could not decode {!r} for unicode trait '{}' of {} instance."
2379 raise TraitError(msg.format(value, self.name, class_of(obj)))
-> 2380 self.error(obj, value)
File ~/.pyenv/versions/3.10.5/envs/pandarallel/lib/python3.10/site-packages/traitlets/traitlets.py:827, in TraitType.error(self, obj, value, error, info)
821 else:
822 e = "The '{}' trait expected {}, not {}.".format(
823 self.name,
824 self.info(),
825 describe("the", value),
826 )
--> 827 raise TraitError(e)
TraitError: The 'value' trait of a Textarea instance expected a unicode string, not the NoneType None. |
Author
|
The PR is 8 months old. If you think the feature is worth I can spend some time in trying to fix it to the current master and correspondent ipywidgets update (in the meantime there was a major upgrade) |
Owner
|
@paoloalba yes sure! |
Owner
|
Pandaral·lel is looking for a maintainer! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.