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

ogma-core: Provide ability to pass format definition specification using local file #200

Closed
ivanperez-keera opened this issue Jan 19, 2025 · 6 comments
Assignees
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Feature Admin only: Change request pertaining to new features requested
Milestone

Comments

@ivanperez-keera
Copy link
Member

Description

Ogma allows users to select the format used for the JSON file, but only known formats can be selected. Users should be able to pass a local file containing a JSON format specification as an argument.

Type

  • Feature: new capability.

Additional context

None.

Requester

  • Ivan Perez.

Method to check presence of bug

Not applicable (not a bug).

Expected result

Users can provide a file as JSON format specification as argument.

Desired result

Users can provide a file as JSON format specification as argument.

Proposed solution

Modify treatment of format name in ogma-core so that, if a file exists with that name, it is used instead.

Further notes

None.

@ivanperez-keera ivanperez-keera added CR:Status:Initiated Admin only: Change request that has been initiated CR:Type:Feature Admin only: Change request pertaining to new features requested labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Change Manager: Confirmed that the issue exists.

@ivanperez-keera ivanperez-keera added CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager and removed CR:Status:Initiated Admin only: Change request that has been initiated labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Technical Lead: Confirmed that the issue should be addressed.

@ivanperez-keera ivanperez-keera added CR:Status:Accepted Admin only: Change request accepted by technical lead and removed CR:Status:Confirmed Admin only: Change request that has been acknowledged by the change manager labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Technical Lead: Issue scheduled for fixing in Ogma 1.6.0.

Fix assigned to: @ivanperez-keera .

@ivanperez-keera ivanperez-keera added CR:Status:Scheduled Admin only: Change requested scheduled and removed CR:Status:Accepted Admin only: Change request accepted by technical lead labels Jan 19, 2025
@ivanperez-keera ivanperez-keera self-assigned this Jan 19, 2025
@ivanperez-keera ivanperez-keera added this to the 1.6.0 milestone Jan 19, 2025
@ivanperez-keera ivanperez-keera added CR:Status:Implementation Admin only: Change request that is currently being implemented and removed CR:Status:Scheduled Admin only: Change requested scheduled labels Jan 19, 2025
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
…efs nasa#200.

Ogma allows users to select the format used for the JSON file, but only
known formats can be selected. Users should be able to pass a local file
containing a JSON format specification as an argument.

This commit modifies the standalone backend so that, if a file exists
with the name of the format selected, or if the format name contains a
path separator, then it is treated as a local file. Otherwise, Ogma
finds the file in the package's data directory.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
… Refs nasa#200.

Ogma allows users to select the format used for the JSON file, but only
known formats can be selected. Users should be able to pass a local file
containing a JSON format specification as an argument.

This commit modifies the standalone backend so that, if a file exists
with the name of the format selected, or if the format name contains a
path separator, then it is treated as a local file. Otherwise, Ogma
finds the file in the package's data directory.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Implementor: Solution implemented, review requested.

@ivanperez-keera ivanperez-keera added CR:Status:Verification Admin only: Change request that is currently being verified and removed CR:Status:Implementation Admin only: Change request that is currently being implemented labels Jan 19, 2025
@ivanperez-keera
Copy link
Member Author

Change Manager: Verified that:

  • Solution is implemented:
    • The code proposed compiles and passes all tests. Details:
    • The solution proposed produces the expected result. Details:
      The following dockerfile checks that a known format can still be used, and that, if a custom provided format is specified in the command line, it is picked up instead and used to parse the input file, in both cases checking also that the resulting monitor compiles successfully, after which it prints the message "Success":
      --- Dockerfile-verify-200
      FROM ubuntu:trusty
      
      RUN apt-get update
      
      RUN apt-get install --yes software-properties-common
      RUN add-apt-repository ppa:hvr/ghc
      RUN apt-get update
      
      RUN apt-get install --yes ghc-8.6.5 cabal-install-2.4
      RUN apt-get install --yes libz-dev
      
      ENV PATH=/opt/ghc/8.6.5/bin:/opt/cabal/2.4/bin:$PWD/.cabal-sandbox/bin:$PATH
      
      RUN cabal update
      RUN cabal v1-sandbox init
      RUN cabal v1-install alex happy --constraint='happy < 2.0'
      RUN apt-get install --yes git
      
      ADD json-custom-format /tmp/json-custom-format
      ADD properties.json /tmp/properties.json
      
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-install copilot-4.2 $NAME/$PAT**/ && \
          ogma standalone --input-format fdb --file-name $NAME/ogma-cli/examples/DB.json --target-dir output1 && \
          cabal v1-exec -- runhaskell -XPartialTypeSignatures -Wno-partial-type-signatures output1/Copilot.hs && \
          ogma standalone --input-format /tmp/json-custom-format --file-name /tmp/properties.json --target-dir output2 && \
          cabal v1-exec -- runhaskell output2/Copilot.hs && \
          echo "Success"
      
      --- json-custom-format
      JSONFormat
         { specInternalVars    = Just "..internal_vars[*]"
         , specInternalVarId   = ".name"
         , specInternalVarExpr = ".meaning"
         , specInternalVarType = Just ".type"
         , specExternalVars    = Just "..other_vars[*]"
         , specExternalVarId   = ".name"
         , specExternalVarType = Just ".type"
         , specRequirements    = "..requirements[*]"
         , specRequirementId   = ".id"
         , specRequirementDesc = Just ".text"
         , specRequirementExpr = ".formula"
         }
      
      -- properties.json
      {
        "spec": {
          "internal_vars": [],
          "other_vars": [
            {"name":"param", "type":"bool"}
          ],
          "requirements": [
            {
              "id":      "req001",
              "formula": "(H param)",
              "text":    "param is always true"
            }
          ]
        }
      }
      
      Command (substitute variables based on new path after merge):
      $ docker run -e "REPO=https://github.com/ivanperez-keera/ogma" -e "NAME=ogma" -e "PAT=ogma" -e "COMMIT=b1316063bc6ca4e930722d064be430c37cbbbb98" -it ogma-verify-200
      
  • Implementation is documented. Details:
    The code that implements this feature includes comments that explain what is being done, and all top-level definitions introduce include haddock documentation.
  • Change history is clear.
  • Commit messages are clear.
  • Changelogs are updated.
  • Examples are updated. Details:
    No updates needed.
  • Required version bumps are evaluated. Details:
    Bump not required (API is backwards compatible).

@ivanperez-keera
Copy link
Member Author

Change Manager: Implementation ready to be merged.

@ivanperez-keera ivanperez-keera added CR:Status:Closed Admin only: Change request that has been completed and removed CR:Status:Verification Admin only: Change request that is currently being verified labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Feature Admin only: Change request pertaining to new features requested
Projects
None yet
Development

No branches or pull requests

1 participant