Code Monkey home page Code Monkey logo

Comments (6)

ncilfone avatar ncilfone commented on June 18, 2024 1

#39 should finally round this out. Example output below.

class Choice(Enum):
    """Blah

    Attributes:
        pear: help pears
        banana: help bananas

    """
    pear = 'pear'
    banana = 'banana'


@spock
class OtherStuff:
    """Other stuff class

    Attributes:
        three: heahadsf
        four: asdfjhasdlkf

    """
    three: int
    four: str


@spock
class Stuff:
    """Stuff class

    Attributes:
        one: help
        two: teadsfa

    """
    one: int
    two: str


class ClassStuff(Enum):
    """Class enum

    Attributes:
        other_stuff: OtherStuff class
        stuff: Stuff class

    """
    other_stuff = OtherStuff
    stuff = Stuff


@spock
class Test:
    """High level docstring that just so happens to be multiline adfjads;lfja;sdlkjfklasjflkasjlkfjal;sdfjlkajsdfl;kja
    adfasfdsafklasdjfkladsjklfasdjlkf

    Mid-level docstring

    Attributes:
        fail: help me obi wan
        test: you are my only hopes
        most_broken: class stuff enum
        new_choice: choice type optionality

    """
    new_choice: Optional[Choice]
    fail: Tuple[Tuple[int, int], Tuple[int, int]]
    test: Optional[List[int]]
    most_broken: ClassStuff
usage: /Users/a635179/Documents/git_repos/open_source/spock/tests/debug/debug.py -c [--config] config1 [config2, config3, ...]

I am a description

configuration(s):

  Test (High level docstring that just so happens to be multiline adfjads;lfja;sdlkjfklasjflkasjlkfjal;sdfjlkajsdfl;kja adfasfdsafklasdjfkladsjklfasdjlkf)
    new_choice     Optional[Choice]                           choice type optionality (default: None)
    fail           Tuple[Tuple[int, int], Tuple[int, int]]    help me obi wan 
    test           Optional[List[int]]                        you are my only hopes (default: None)
    most_broken    ClassStuff                                 class stuff enum 

  Stuff (Stuff class)
    one    int    help 
    two    str    teadsfa 

  OtherStuff (Other stuff class)
    three    int    heahadsf 
    four     str    asdfjhasdlkf 

  Choice (Blah)
    pear      str    help pears 
    banana    str    help bananas 

  ClassStuff (Class enum)
    other_stuff    type    OtherStuff class 
    stuff          type    Stuff class 

from spock.

dorukkilitcioglu avatar dorukkilitcioglu commented on June 18, 2024

Upon further inspection, the high-level description that you can provide during config initialization also isn't printed to the command line. Example:

config = ConfigArgBuilder(ModelConfig, desc='asd').generate()
>>> USAGE:
>>>   spock_test.py -c [--config] config1 [config2, config3, ...]
>>> CONFIG:
>>>   ModelConfig:
>>>     n_features: int
>>>     dropout: Optional[List[float]]
>>>     hidden_sizes: Optional[Tuple[int]]

from spock.

ncilfone avatar ncilfone commented on June 18, 2024

@dorukkilitcioglu WIP branch that implements the core of the request. Print format is similar to argparser for consistency

@spock
class OtherStuff:
    """Other stuff class

    Attributes:
        three: heahadsf
        four: asdfjhasdlkf

    """
    three: int
    four: str


@spock
class Stuff:
    """Stuff class

    Attributes:
        one: help
        two: teadsfa

    """
    one: int
    two: str


class ClassStuff(Enum):
    """Class enum

    Attributes:
        other_stuff: OtherStuff class
        stuff: Stuff class

    """
    other_stuff = OtherStuff
    stuff = Stuff


@spock
class Test:
    """High level docstring that just so happens to be multiline adfjads;lfja;sdlkjfklasjflkasjlkfjal;sdfjlkajsdfl;kja
    adfasfdsafklasdjfkladsjklfasdjlkf

    Mid-level docstring

    Attributes:
        fail: help me obi wan
        test: you are my only hopes
        most_broken: class stuff enum

    """
    fail: Tuple[Tuple[int, int], Tuple[int, int]]
    test: List[int] = [1, 2]
    most_broken: ClassStuff

Running ConfigArgBuilder(Test, Stuff, OtherStuff, desc='I am a description').generate() using the --help flag will print this:

usage: /Users/a635179/Documents/git_repos/open_source/spock/tests/debug/debug.py -c [--config] config1 [config2, config3, ...]

I am a description

configuration(s):

  Test (High level docstring that just so happens to be multiline adfjads;lfja;sdlkjfklasjflkasjlkfjal;sdfjlkajsdfl;kja adfasfdsafklasdjfkladsjklfasdjlkf)
    fail           Tuple[Tuple[int]]    help me obi wan 
    test           List[int]            you are my only hopes (default: [1, 2])
    most_broken    ClassStuff           class stuff enum 

  Stuff (Stuff class)
    one    int    help 
    two    str    teadsfa 

  OtherStuff (Other stuff class)
    three    int    heahadsf 
    four     str    asdfjhasdlkf    

Lmk what you think

from spock.

ncilfone avatar ncilfone commented on June 18, 2024

Top level Enums now get caught by the help print on #39. Still need to figure out some hacky way to grab Enums nested in other types (e.g. List[List[Choice]]) but that should round this out...

class Choice(Enum):
    """Blah

    Attributes:
        pear: help pears
        banana: help bananas

    """
    pear = 'pear'
    banana = 'banana'

@spock
class OtherStuff:
    """Other stuff class

    Attributes:
        three: heahadsf
        four: asdfjhasdlkf

    """
    three: int
    four: str


@spock
class Stuff:
    """Stuff class

    Attributes:
        one: help
        two: teadsfa

    """
    one: int
    two: str


class ClassStuff(Enum):
    """Class enum

    Attributes:
        other_stuff: OtherStuff class
        stuff: Stuff class

    """
    other_stuff = OtherStuff
    stuff = Stuff


@spock
class Test:
    """High level docstring that just so happens to be multiline adfjads;lfja;sdlkjfklasjflkasjlkfjal;sdfjlkajsdfl;kja
    adfasfdsafklasdjfkladsjklfasdjlkf

    Mid-level docstring

    Attributes:
        fail: help me obi wan
        test: you are my only hopes
        most_broken: class stuff enum
        new_choice: choice type optionality

    """
    new_choice: Choice
    fail: Tuple[Tuple[int, int], Tuple[int, int]]
    test: List[int] = [1, 2]
    most_broken: ClassStuff
usage: /Users/a635179/Documents/git_repos/open_source/spock/tests/debug/debug.py -c [--config] config1 [config2, config3, ...]

I am a description

configuration(s):

  Test (High level docstring that just so happens to be multiline adfjads;lfja;sdlkjfklasjflkasjlkfjal;sdfjlkajsdfl;kja adfasfdsafklasdjfkladsjklfasdjlkf)
    new_choice     Choice               choice type optionality 
    fail           Tuple[Tuple[int]]    help me obi wan 
    test           List[int]            you are my only hopes (default: [1, 2])
    most_broken    ClassStuff           class stuff enum 

  Choice (Blah)
    pear      str    help pears 
    banana    str    help bananas 

from spock.

dorukkilitcioglu avatar dorukkilitcioglu commented on June 18, 2024

This is starting to look quite good! Is there a reason why the type for fail is cut short?

from spock.

ncilfone avatar ncilfone commented on June 18, 2024

This is starting to look quite good! Is there a reason why the type for fail is cut short?

Ahhh good question... Recently updated spock in v2.0.0 to handle Tuples different than Lists (Tuples are now length restricted) and I don't think some of the repr of type info got updated. Will fix

from spock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.