Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vscode decorator #2018

Merged
merged 16 commits into from
Dec 15, 2023
Merged

Update vscode decorator #2018

merged 16 commits into from
Dec 15, 2023

Conversation

pingsutw
Copy link
Member

@pingsutw pingsutw commented Dec 3, 2023

Why are the changes needed?

Failed to run the task with vscode decorator locally.

│ ❱ 291 │   │   return wrapper(_task_function)                                 │
│                                                                              │
│ /Users/kevin/git/flytekit/flytekit/core/task.py:269 in wrapper               │
│                                                                              │
│ ❱ 269 │   │   task_instance = TaskPlugins.find_pythontask_plugin(type(task_c │
│                                                                              │
│ /Users/kevin/git/flytekit/flytekit/core/tracker.py:85 in __call__            │
│                                                                              │
│ ❱  85 │   │   o = super(InstanceTrackingMeta, cls).__call__(*args, **kwargs) │
│                                                                              │
│ /Users/kevin/git/flytekit/flytekit/core/python_function_task.py:120 in       │
│ __init__                                                                     │
│                                                                              │
│ ❱ 120 │   │   name, _, _, _ = extract_task_module(task_function)             │
│                                                                              │
│ /Users/kevin/git/flytekit/flytekit/core/tracker.py:327 in                    │
│ extract_task_module                                                          │
│                                                                              │
│ ❱ 327 │   │   inspect_file = inspect.getfile(f)  # type: ignore              │
│                                                                              │
│ /Users/kevin/opt/anaconda3/envs/flytekit-3.10/lib/python3.10/inspect.py:797  │
│ in getfile                                                                   │
│                                                                              │
│ ❱  797 │   raise TypeError('module, class, method, function, traceback, fram │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: module, class, method, function, traceback, frame, or code object was
expected, got vscode

What changes were proposed in this pull request?

  • Update extract_task_module, so we are able to get the task module and name from ClassDecorator
  • Rename _wrap_call to execute
  • Add more tests

How was this patch tested?

Run a task with vscode decorator locally

from flytekitplugins.flyin import vscode
from flytekit import task


@task
@vscode(enable=True)
def t1(a: int, b: int) -> int:
    return a // b


if __name__ == '__main__':
    print(t1(a=6, b=3))

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Copy link

codecov bot commented Dec 3, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (47e15b6) 85.98% compared to head (8d5d7cd) 84.87%.
Report is 2 commits behind head on master.

Files Patch % Lines
flytekit/core/tracker.py 0.00% 3 Missing ⚠️
...lyin/flytekitplugins/flyin/vscode_lib/decorator.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2018      +/-   ##
==========================================
- Coverage   85.98%   84.87%   -1.12%     
==========================================
  Files         308      258      -50     
  Lines       22946    20763    -2183     
  Branches     3468     3475       +7     
==========================================
- Hits        19731    17622    -2109     
+ Misses       2615     2536      -79     
- Partials      600      605       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
@pingsutw pingsutw marked this pull request as ready for review December 4, 2023 19:46
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
Signed-off-by: Kevin Su <pingsutw@apache.org>
else:
# If self.func is None, it means decorator was called with arguments.
# Therefore, __call__ received the actual function to be decorated.
# We return a new instance of ClassDecorator with the function and stored arguments.
return self.__class__(args[0], **self.decorator_kwargs)

@abstractmethod
def _wrap_call(self, *args, **kwargs):
def execute(self, *args, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

abstractmethod instead of NotImplementedError?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Kevin Su <pingsutw@apache.org>
ByronHsu
ByronHsu previously approved these changes Dec 6, 2023
@pingsutw pingsutw self-assigned this Dec 13, 2023
Signed-off-by: Kevin Su <pingsutw@apache.org>
@eapolinario
Copy link
Collaborator

Signed-off-by: Kevin Su <pingsutw@apache.org>
@pingsutw pingsutw merged commit f1f8aef into master Dec 15, 2023
74 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants