hey there, sorry I hadn't responded to this.

is your tool reformatting Python code?   I don't see anything "wrong" with it 
other than the code looks kind of verbose.    This would be a matter of 
personal preference but if it were me I'd want each attribute to have a string 
description listed out only once in the source code so that it may be edited 
directly.   then as far as how it appears in Sphinx and/or DDL there would be 
transparent extensions that make that happen.



On Sun, Jan 24, 2021, at 12:14 AM, Samuel Marks wrote:
> Would be great to have some insight here. If I'm going to start generating 
> to/fro SQLalchemy models, then I need to get the column descriptions right
> 
> Samuel Marks
> Charity <https://sydneyscientific.org/> | consultancy <https://offscale.io/> 
> | open-source <https://github.com/offscale> | LinkedIn 
> <https://linkedin.com/in/samuelmarks>
> 
> 
> On Tue, Jul 28, 2020 at 5:57 PM Samuel Marks <sam...@offscale.io> wrote:
>> I have created a little tool—at the AST level—to translate between 
>> docstrings, methods, classes, and argparse. 
>> https://github.com/SamuelMarks/doctrans
>> 
>> Now looking at adding SQLalchemy support.
>> 
>> Using the mock 
>> <https://github.com/SamuelMarks/doctrans/tree/f35963b/doctrans/tests/mocks> 
>> I've been using throughout, does this look like the 'right' kind of 
>> SQLalchemy code?
>> 
>> *class *Model(Base):
>>     *"""
**    Acquire from the official tensorflow_datasets model zoo, or the 
ophthalmology focussed ml-prepare library
**
**    :cvar dataset_name: name of dataset. Defaults to mnist
**    :cvar tfds_dir: directory to look for models in. Defaults to 
~/tensorflow_datasets
**    :cvar K: backend engine, e.g., `np` or `tf`. Defaults to np
**    :cvar as_numpy: Convert to numpy ndarrays
**    :cvar data_loader_kwargs: pass this as arguments to data_loader function
**    """
**    *__tablename__ = *'model'
**
**    *dataset_name = Column(String, primary_key=*True*, default=*'mnist'*,
>>                           comment=*'name of dataset'*, doc=*'name of 
>> dataset'*)
>>     tfds_dir = Column(String, default=*'~/tensorflow_datasets'*,
>>                       comment=*'directory to look for models in'*, 
>> doc=*'directory to look for models in'*)
>>     K = Column(String, default=*'np'*,
>>                comment=*'backend engine, e.g., `np` or `tf`'*, doc=*'backend 
>> engine, e.g., `np` or `tf`'*)
>>     as_numpy = Column(Boolean,
>>                       comment=*'Convert to numpy ndarrays'*, doc=*'Convert 
>> to numpy ndarrays'*)
>>     data_loader_kwargs = Column(*'data_loader_kwargs'*, JSON,
>>                                 comment=*'pass this as arguments to 
>> data_loader function'*,
>>                                 doc=*'pass this as arguments to data_loader 
>> function'*)
>> 
>>     *# _return_type = 'Train and tests dataset splits. Defaults to 
>> (np.empty(0), np.empty(0))'
**
**    **def *__repr__(self):
>>         *"""
**        :returns: String representation of constructed object
**        :rtype: ```str```
**        """
**        **return **'<Model(dataset_name={self[dataset_name]!r},' *\
>>                *'       tfds_dir={self[tfds_dir]!r},' *\
>>                *'       K={self[K]!r},' *\
>>                *'       as_numpy={self[as_numpy]!r},' *\
>>                *'       data_loader_kwargs={self[data_loader_kwargs]!r}' *\
>>                *')>'*.format(self=self)
>> 
>> If not, what should it look like?
>> 
>> Thanks for your suggestions
>> 

>> -- 
>> SQLAlchemy - 
>> The Python SQL Toolkit and Object Relational Mapper
>>  
>> http://www.sqlalchemy.org/
>>  
>> To post example code, please provide an MCVE: Minimal, Complete, and 
>> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
>> description.
>> --- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "sqlalchemy" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/sqlalchemy/xZAh5zPswM0/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sqlalchemy/6576d789-d088-4e68-a7f7-a17b5c96a810o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sqlalchemy/6576d789-d088-4e68-a7f7-a17b5c96a810o%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 

> -- 
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
>  
> http://www.sqlalchemy.org/
>  
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/CAGOFhkTFRjQpTiNwM%2BMSX3dw95KGUhX-ATCpNbb_YRhZRM%2B5Rw%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/CAGOFhkTFRjQpTiNwM%2BMSX3dw95KGUhX-ATCpNbb_YRhZRM%2B5Rw%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/ee539bc2-67a9-4831-99e9-5e65bc527d84%40www.fastmail.com.

Reply via email to