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

Copyright date in yaml and nxdl files. #46

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

RubelMozumder
Copy link
Collaborator

No description provided.

@lukaspie lukaspie linked an issue Jan 14, 2025 that may be closed by this pull request
is_comment_start = False
is_comment_end = False

if os.path.isfile(nxdl_file):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be careful! This function gets the copyright section from a given file. Note that during the conversion

  • nxdl->nyaml: we just copy the whole nxdl file to the end of the yaml file
  • nyaml->nxdl: we need to generate the copyright from the content of the original nxdl(!) (which is actually appended to the end of the nyaml file).

Copy link
Collaborator Author

@RubelMozumder RubelMozumder Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is exactly what is happening. The nxdl_file is coming the copied/stored ( in yaml file) nxdl content from yaml file. In function generate_nxdl_or_retrieve_nxdl cli.py that returns the copied/stored nxdl part as a output file if there is no changes in the yaml part. Otherwise it send the copied/stored nxdl content to the nyaml2nxdl, that is overwriten later on.
So, in all cases copyright license content is coming from stored nxdl in yaml file.

You can check this function https://github.com/FAIRmat-NFDI/nyaml/blob/copyright_year/src/nyaml/cli.py#L46.

@@ -1155,6 +1175,8 @@ def nyaml2nxdl(input_file: str, out_file, verbose: bool):
schema, definitions then evaluates a nested dictionary of groups recursively and
fields or (their) attributes as children of the groups
"""
nxdl_copyright_license = get_nxdl_copyright_license(nxdl_file=out_file)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is calling the function with the name of output file, which may not even exists.
In case of nxdl->nyaml conversion one could call this function with the input file name. In case of nyaml->nxdl conversion the copyright should be in the nyaml file as part of the preserved nxdl conent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two possibility:

  1. File exists (coming from stored nxdl in yaml):
    It would returns the copyright license from previous version of nxdl.
  2. File does not exist (For new yaml file that does not have any nxdl):
    The function would return an empty string "".

@@ -3,7 +3,7 @@
<!--
# NeXus - Neutron and X-ray Common Data Format
#
# Copyright (C) 2014-2024 NeXus International Advisory Committee (NIAC)
# Copyright (C) 2025-2025 NeXus International Advisory Committee (NIAC)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this test will only work in 2025

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, every year it should be updated.
The is the test for conversion from new yaml to nxdl.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now copyright year is independent of the year of test.
Current test will check if the <current_year>-<current_year> it correct (if there are no nxdl file stored in the yaml file as comment.), then the years will be replaced according to the test/nxdl file which is 2010-2020 hard coded in all nxdl file.

@sanbrock
Copy link
Collaborator

sanbrock commented Jan 14, 2025

do we test this use cases?

  • nxdl -convert-> nyaml -convert-> nxdl2 (so the new nxdl file and the original are bytewise the same if nyaml was not edited
  • nxdl -convert-> nyaml -edited-> nyaml2 -convert -> nxdl2 (so only the intended modifications are performed in the file and the original copyright message is preserved)
  • nyaml -convert-> nxdl (so it creates an nxdl file with a proper copyright showing the current dates)
  • nyaml -> convert -> nxdl -convert-> nyaml2 (son the new yaml file contains the copyright in its appended nxdl content)

@RubelMozumder
Copy link
Collaborator Author

do we test this use cases?

  • nxdl -convert-> nyaml -convert-> nxdl2 (so the new nxdl file and the original are bytewise the same if nyaml was not edited
  • nxdl -convert-> nyaml -edited-> nyaml2 -convert -> nxdl2 (so only the intended modifications are performed in the file and the original copyright message is preserved)
  • nyaml -convert-> nxdl (so it creates an nxdl file with a proper copyright showing the current dates)
  • nyaml -> convert -> nxdl -convert-> nyaml2 (son the new yaml file contains the copyright in its appended nxdl content)

I wrote a separate test for that.

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

Successfully merging this pull request may close these issues.

NYAML shall not modify the license section
2 participants