Skip to content
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

Semantics #3

Open
samwaseda opened this issue Nov 7, 2023 · 2 comments
Open

Semantics #3

samwaseda opened this issue Nov 7, 2023 · 2 comments

Comments

@samwaseda
Copy link
Member

@mbercx @jan-janssen @JaGeo @schaarj

I started creating semantics.md. The definition of parser is more or less what @mbercx and I agreed on, but there are the following points I was not so sure about:

  • An input parser does not return anything for file-based software
  • What is an input parser supposed to do for python-based software (e.g. interactive LAMMPS)

And on top of this, we might have to make a distinction between requirements and recommendations.

By the way, obviously you are also very welcome to make changes there.

@mbercx
Copy link
Collaborator

mbercx commented Nov 19, 2023

Thanks @samwaseda! I had a quick look, and expanded a bit on the text in #4.

An input parser does not return anything for file-based software

I'm not sure what you mean here? I was actually wondering about the functions of an input parser. In the context of e.g. VASP, should it both be able to:

  1. take an INCAR file and parse the contents into e.g. a Python dict?
  2. generate an INCAR from e.g. a Python dict?

The answer to (1) seems like an obvious yes, but (2) I would not call "parsing". More like "input file generation". ^^ One distinction between input/output parsers is that you typically don't need an output parser to be able to generate the contents of e.g. a VASP stdout.

What is an input parser supposed to do for python-based software (e.g. interactive LAMMPS)

It's an interesting point, and I hadn't considered this in the context of parsing. Is taking the output of a Python function (e.g. a dict) and converting it into an established format or schema considered to be "parsing"? Or do we consider this to be more like "converting" one data format into another?

Let's say we would write an output parser for the VASP stdout, which would output a dictionary in a format which is VASP-specific. Afterwards we want to take that dictionary and convert it into a standardized format which we all agreed upon1. Is this second operation also considered to be "parsing"? Are we dealing with parser-ception here?

Footnotes

  1. a decade from now, I imagine. ^^

@samwaseda
Copy link
Member Author

  1. take an INCAR file and parse the contents into e.g. a Python dict?
  2. generate an INCAR from e.g. a Python dict?

ah, an interesting point. I was blindly thinking about 2., but it's true that if we stick to the term "parser", it makes more sense to talk about 1., although in the concept of a workflow, it's more about 2.

So my suggestion was related to 2., and it would more specifically look like this:

def write_incar(incar_dict, cwd):
    with open(cwd + "/INCAR", "w") as f:
        for k, v in incar_dict.items():
            f.write(k + " " + str(v) + "\n")
    return None

JaGeo pushed a commit to JaGeo/ADIS2023 that referenced this issue Jul 8, 2024
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

No branches or pull requests

2 participants