microsoft / microsoft/Trace

Programmatically update Docstring

Open
#47 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
759
Forks
63
PR merge metrics
No merged PRs in 30d

Description

Hi,

I want to use Trace to build an application to let non-engineers optimized code for certain tasks. Ideally I would like to have an f-string in place of the docstring for a number of bundled functions that are methods on classes decorated by @model but of course python requires docstrings be a string literal. I'm REALLY trying to avoid resorting to a templating library for this. Currently I am trying to update the docstring of a number of bundled functions through some combination of bundled_function.description bundled_function.info['doc'] bundled_function._fun.__doc__ but so far no matter what I do I can't see the new docstring in the parameters of either the function node or in the associated optimizers.

Do you all have a suggestion of how I could implement a templated docstring? For reference here's a SUPER minimal example of what I mean:

@bundle some_func(input_data):
f"""input_data is {data_description}. 
You need to {task_description}. 
Make sure you don't {caveats_description}.
"""
    pass

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how @bundle functions expose bundled_function.description, bundled_function.info['doc'], and bundled_function._fun.doc, then follow how function-node parameters and associated optimizers consume those values. Done would mean a supported way to provide templated docstrings whose rendered text appears in both the function node parameters and associated optimizers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
ai
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.