Skip to content

Update example to exclude external modules #215

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

Merged
merged 1 commit into from
Jan 30, 2025

Conversation

bagel897
Copy link
Contributor

Motivation

Content

Testing

Please check the following before marking your PR as ready for review

  • I have added tests for my changes
  • I have updated the documentation or added new documentation as needed
  • I have read and agree to the Contributor License Agreement

@bagel897 bagel897 marked this pull request as ready for review January 30, 2025 18:38
@bagel897 bagel897 requested review from codegen-team and a team as code owners January 30, 2025 18:38
@bagel897 bagel897 requested review from EdwardJXLi and removed request for a team January 30, 2025 18:38
@bagel897 bagel897 changed the title Update example Update example to exclude external modules Jan 30, 2025
@bagel897 bagel897 enabled auto-merge (squash) January 30, 2025 18:38
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files

@bagel897 bagel897 merged commit bca7abb into develop Jan 30, 2025
8 checks passed
@bagel897 bagel897 deleted the eagarwal-cg-10605-update-call-graph-example branch January 30, 2025 18:41
@JohnPeng47
Copy link

Thanks. Im good to close this out, but just an FYI, I needed this line or else the call fails as well:

    def traverse_calls(parent_func, current_depth):
        if current_depth > max_depth:
            return

        # Determine source node
        if isinstance(parent_func, Function):
            src_call = src_func = parent_func
        else:
            src_func = parent_func.function_definition
            src_call = parent_func


        print(f"Func[{current_depth}]: {src_func.name}")
        
        # Missing definitions for python libs
        if isinstance(src_func, ExternalModule):
            return

        # Traverse all function calls
        for call in src_func.function_calls:
            func = call.function_definition

            # THIS LINE IS ALSO REQUIRED; FAILS IF NOT ADDED
            if not func:
                continue

            # Skip recursive calls
            if func.name == src_func.name:
                continue

            # Add nodes and edges
            G.add_node(call)
            G.add_edge(src_call, call)

            # Check if we reached the target
            if func == end_func:
                G.add_edge(call, end_func)
                return

            # Continue traversal
            traverse_calls(call, current_depth + 1)


@JohnPeng47
Copy link

Yeah Im good to close

jayhack pushed a commit that referenced this pull request Feb 9, 2025
# Motivation
<!-- Why is this change necessary? -->

# Content
<!-- Please include a summary of the change -->
# Testing
<!-- How was the change tested? -->
# Please check the following before marking your PR as ready for review

- [ ] I have added tests for my changes
- [ ] I have updated the documentation or added new documentation as
needed
- [ ] I have read and agree to the [Contributor License
Agreement](/codegen-sh/codegen-sdk/blob/develop/CLA.md)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants