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: FPrime backend now requires JAVA #206

Closed
ivanperez-keera opened this issue Jan 20, 2025 · 6 comments
Closed

ogma-core: FPrime backend now requires JAVA #206

ivanperez-keera opened this issue Jan 20, 2025 · 6 comments
Assignees
Labels
CR:Status:Closed Admin only: Change request that has been completed CR:Type:Bug Admin only: Change request pertaining to error detected
Milestone

Comments

@ivanperez-keera
Copy link
Member

Description

The FPrime backend now requires java, which makes the generated Dockerfile no longer compile.

Type

  • Bug: Generated docker image does not build.

Additional context

None.

Requester

  • Ivan Perez.

Method to check presence of bug

Running the FPrime backend and compiling the generated code with the following files breaks when trying to build the docker image generated by Ogma:

$ ogma standalone --file-name /tmp/document.json -f /tmp/json-format.cfg -p literal --target-file-name copilot --target-dir fprime_demo
$ ogma fprime --app-target-dir fprime_demo --handlers-file /tmp/fprime-handlers --input-file /tmp/document.json -f /tmp/json-format.cfg -p literal --variable-db /tmp/fprime-variable-db
$ cabal v1-exec -- runhaskell fprime_demo/Copilot.hs
$ mv copilot* fprime_demo/
$ cd fprime_demo/
$ docker build -t ogma fprime-demo .

Auxiliary files:

--- document.json
{
  "Example": {
    "internal_variables": [],
    "external_variables": [
      {"name":"input", "type":"Float", "meaning": "Input from the system"}
    ],
    "properties": [
      {
        "id":      "MyProperty",
        "formula": "PTLTL.alwaysBeen (input /= 30.0)",
        "text":    "Input is never 30"
      }
    ]
  }
}

--- fprime-handlers
handlerMyProperty

--- fprime-variable-db
("pullup", "bool")
("input", "float")

--- json-format.cfg
JSONFormat
   { specInternalVars    = Just "..internal_variables[*]"
   , specInternalVarId   = ".name"
   , specInternalVarExpr = ".meaning"
   , specInternalVarType = Just ".type"
   , specExternalVars    = Just "..external_variables[*]"
   , specExternalVarId   = ".name"
   , specExternalVarType = Just ".type"
   , specRequirements    = "..properties[*]"
   , specRequirementId   = ".id"
   , specRequirementDesc = Just ".text"
   , specRequirementExpr = ".formula"
   }

These build steps break with the message:

fpp tools require 'java'. Please install 'java' and ensure it is in your PATH.

Expected result

The build steps above should complete successfully.

Desired result

The build steps above should complete successfully.

Proposed solution

Modify Dockerfile in the default FPrime template to install default-jre.

Further notes

None.

@ivanperez-keera ivanperez-keera added CR:Status:Initiated Admin only: Change request that has been initiated CR:Type:Bug Admin only: Change request pertaining to error detected labels Jan 20, 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 20, 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 20, 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 21, 2025
@ivanperez-keera ivanperez-keera self-assigned this Jan 21, 2025
@ivanperez-keera ivanperez-keera added this to the 1.6.0 milestone Jan 21, 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 21, 2025
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 21, 2025
…. Refs nasa#206.

The FPrime backend now requires Java, which makes the generated Dockerfile no
longer compile.

This commit adds the default Java runtime to the Ubuntu docker image generated
by Ogma's FPrime backend.
ivanperez-keera added a commit to ivanperez-keera/ogma that referenced this issue Jan 21, 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 21, 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 uses the standalone backend to generate a monitor using a literal Copilot expression gathered from a custom JSON file, and then uses the FPrime backend to produce an FPrime component. The Copilot monitor is further compiled, and building the Dockerfile generated by the FPrime backend completes the compilation process correctly.
      --- Dockerfile-verify-206
      FROM ubuntu:trusty
      
      ENV DEBIAN_FRONTEND=noninteractive
      
      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
      RUN apt-get install --yes git
      
      ADD document.json      /tmp/document.json
      ADD json-format.cfg    /tmp/json-format.cfg
      ADD fprime-variable-db /tmp/fprime-variable-db
      ADD fprime-handlers    /tmp/fprime-handlers
      
      CMD git clone $REPO && \
          cd $NAME && \
          git checkout $COMMIT && \
          cd .. && \
          cabal v1-sandbox init && \
          cabal v1-install copilot-4.2 $NAME/$PAT**/ --constraint="aeson>=2.0.3.0" && \
          ./.cabal-sandbox/bin/ogma standalone --file-name /tmp/document.json -f /tmp/json-format.cfg -p literal --target-file-name copilot --target-dir fprime_demo && \
          ./.cabal-sandbox/bin/ogma fprime --app-target-dir fprime_demo --handlers-file /tmp/fprime-handlers --input-file /tmp/document.json -f /tmp/json-format.cfg -p literal --variable-db /tmp/fprime-variable-db && \
          cabal v1-exec -- runhaskell fprime_demo/Copilot.hs && \
          sed -i -e '0,/RUN apt-get install/{s/\(RUN apt-get install .*\)/\1 default-jre/}' fprime_demo/Dockerfile && \
          mv copilot* fprime_demo/
      
      --- document.json
      {
        "Example": {
          "internal_variables": [],
          "external_variables": [
            {"name":"input", "type":"Float", "meaning": "Input from the system"}
          ],
          "properties": [
            {
              "id":      "MyProperty",
              "formula": "PTLTL.alwaysBeen (input /= 30.0)",
              "text":    "Input is never 30"
            }
          ]
        }
      }
      
      --- fprime-handlers
      handlerMyProperty
      
      --- fprime-variable-db
      ("pullup", "bool")
      ("input", "float")
      
      --- json-format.cfg
      JSONFormat
         { specInternalVars    = Just "..internal_variables[*]"
         , specInternalVarId   = ".name"
         , specInternalVarExpr = ".meaning"
         , specInternalVarType = Just ".type"
         , specExternalVars    = Just "..external_variables[*]"
         , specExternalVarId   = ".name"
         , specExternalVarType = Just ".type"
         , specRequirements    = "..properties[*]"
         , specRequirementId   = ".id"
         , specRequirementDesc = Just ".text"
         , specRequirementExpr = ".formula"
         }
      
      Command (substitute variables based on new path after merge):
      $ docker run -v $PWD/fprime_demo:/fprime_demo -e "REPO=https://github.com/ivanperez-keera/ogma" -e "NAME=ogma" -e "PAT=ogma" -e "COMMIT=cd668a65f9baa4072ebcb8457941007ed7beae93" -it ogma-verify-206
      $ cd fprime_demo
      $ docker build -t ogma-verify-206-fprime -f Dockerfile .
      
  • Implementation is documented. Details:
    No updates needed.
  • 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 needed (bug fix for compatibility with newer versions of dependencies).

@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 21, 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:Bug Admin only: Change request pertaining to error detected
Projects
None yet
Development

No branches or pull requests

1 participant