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

Existing local relative path for reference files is not resolved #66

Open
AndreaBartolini opened this issue Mar 4, 2024 · 0 comments
Open

Comments

@AndreaBartolini
Copy link
Contributor

AndreaBartolini commented Mar 4, 2024

I currently run the CI on my PC and the reference files are placed in a directory that has the following relative path starting from the python script directory:

../../LibRefResults/zLibTest2

my config file is the following:

[
  {
    "library":"zLibTest2",
    "referenceFiles":"../../LibRefResults/zLibTest2"
  }  
]

When I run the script the relative path is not resolved and it is copied "as is" in the .json file that is used by the testModel.py script, with the result that the reference variables are not found by omc.
It seems that the cause of this is the following code recently added to the test.py script:

    if isinstance(c["referenceFiles"], (str, bytes)):
      m = re.search("^[$][A-Z]+", c["referenceFiles"])
      if m:
        k = m.group(0)[1:]
        if k not in os.environ:
          raise Exception("Environment variable %s not defined, but used in JSON config for reference files" % k)
        c["referenceFiles"] = c["referenceFiles"].replace(m.group(0), os.environ[k])

that refuses my path because it is a string that not respect the requirments of the regular expression (i.e., is is not an environment variable)

I think there might be an error in the indentation of the second elif case:

    if isinstance(c["referenceFiles"], (str, bytes)):
      m = re.search("^[$][A-Z]+", c["referenceFiles"])
      if m:
        k = m.group(0)[1:]
        if k not in os.environ:
          raise Exception("Environment variable %s not defined, but used in JSON config for reference files" % k)
        c["referenceFiles"] = c["referenceFiles"].replace(m.group(0), os.environ[k])
    elif "giturl" in c["referenceFiles"]:
      refFilesGitTag = "origin/master"
      if "git-ref" in c["referenceFiles"]:
        refFilesGitTag = c["referenceFiles"]["git-ref"].strip()
   .... etc

that never is tested if c["referenceFiles"] is a string, maybe the right indentation is the following,

    if isinstance(c["referenceFiles"], (str, bytes)):
      m = re.search("^[$][A-Z]+", c["referenceFiles"])
      if m:
        k = m.group(0)[1:]
        if k not in os.environ:
          raise Exception("Environment variable %s not defined, but used in JSON config for reference files" % k)
        c["referenceFiles"] = c["referenceFiles"].replace(m.group(0), os.environ[k])
      elif "giturl" in c["referenceFiles"]:
        refFilesGitTag = "origin/master"
        if "git-ref" in c["referenceFiles"]:
          refFilesGitTag = c["referenceFiles"]["git-ref"].strip()
   .... etc

that probably solves also this issue.

@AndreaBartolini AndreaBartolini changed the title existing local path for reference files not accepted Existing local relative path for reference files is not accepted Mar 4, 2024
@AndreaBartolini AndreaBartolini changed the title Existing local relative path for reference files is not accepted Existing local relative path for reference files is not resolved Mar 4, 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

1 participant