Code formating, typing, clenup, docstrings ... #321
Replies: 4 comments
-
Hi @marian-code Thank you very much for the proposal. I totally agree with you that the code style and the documentation of DeePMD-kit need to be improved. At the current stage, the interfaces of classes are subject to change. For example, the initializer of I would suggest adopt the changes you are proposing after the change of interfaces. Best regards, |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick reply @amcadmus, I agree that in a way it makes sense to wait until the chances are finalized. But on the other hand as it is a lot of work and surely not everything will be changed I think it makes sense to start early. Improving code style and documentation can also help to identify places in code that need to be rewritten and may result in easier transition process. Let me use the example from typing import List
from typing_extensions import TypedDict
JDATA = TypedDict("JDATA", {
'sel': List[int],
'rcut': float,
'rcut_smth': float,
'neuron': List[int],
'axis_neuron': int,
'resnet_dt': bool,
'trainable': bool,
'seed': int,
'type_one_side': bool,
'exclude_types': list,
'set_davg_zero': bool,
'activation_function': str,
'precision': str
})
class DescrptSeA ():
def __init__ (self, jdata: JDATA):
... Typing can be used to to clarify which keys with corresponding value types must be present. The If I may ask is there an estimated time when the API will be stable? Maybe this could be done by opening a parallel branch to devel where the changes would be slowly implemented (at least on parts of the code that are considered stable enough) and then desired commits could be merged into devel branch using something like In summary what I ment to say was that the work done even now when API is not stable is certainly not completely in vain. Even though that some things will need to be done more times over as the code changes I think there might still be a considerable benefit to this approach. Best regards, Marián |
Beta Was this translation helpful? Give feedback.
-
Hi Marián, Thanks a lot for your suggestions. You are referred to the new branch https://github.com/amcadmus/deepmd-kit/tree/api for the progress of the APIs. By far I have finished descrpt_se_a and fitting. Any comment and criticism is welcome! We are planning to finish it as soon as possible, for example 1 to 2 weeks. Best, |
Beta Was this translation helpful? Give feedback.
-
Thank you for the ref. to the api branch. I will have a look at it as soon as I find the time. I didn't think you would be planing to finish in such short time. This brings new perspective. Now I agree it certainly makes sense to wait until the rewrite is complete and only than implement these changes. |
Beta Was this translation helpful? Give feedback.
-
I enjoy working with deepmd kit and I like that new functionality can be added quite easily as much of it is written in python. But the codebase has grown considerably and is now really hard to read and understand. This slows the developement and creates a high barrier for anyone that wants to implement new features to the code or even just check on somethink in the code. I think deepmd-kit could greatly benefit from use of some standardized formating, type hints and at least minimal standardized docstrings.
The changes I propose are:
I have started the discussion here as I would be willing to implement the features outlined one by one but I need to know if such PRs would be accepted as it is quite a lot of work.
I suggest use of Black to enforce consistent style as it is really strict and does not give user the option to bring in his onw formating. Python typing standard library module for extensive types and MyPy static typechecker to enforce typehints. Lastly Numpy docstring standard as it is perhaps the most commonly used one.
These are just my suggestions, all is up for discussion. I would like to hear your thoughts on the matter.
Beta Was this translation helpful? Give feedback.
All reactions