find file location sent as a non-compressed artifact

0

I have a python greengrass component that in itself is in a compressed artifact. I also have a non-compressed artifact in test/route.nmea that i want to access from within the python component.

 "Artifacts": [
        {
          "URI": "s3://jeteye/components/artifacts/au.com.company.gg_gps_publish/0.0.123/gg_gps_publish.zip",
          "Unarchive": "ZIP"
        },
        {
          "URI": "s3://jeteye/components/artifacts/au.com.company.gg_gps_publish/0.0.123/test/route.nmea",
          "Unarchive": "NONE"
        }

i tried: g_nmea_file = os.path.dirname(os.path.abspath(__file__)) + '/../test/route.nmea' but that ends up pointing to the decompressed artifact directory :

/greengrass/v2/packages/artifacts-unarchived/au.com.company.gg_gps_publish/0.0.123/gg_gps_publish/test/route.nmea

is there a greengrass call to get access the non-unarchived artifact directory like:

/greengrass/v2/packages/artifacts/au.com.company.gg_gps_publish/0.0.123/gg_gps_publish/

?

I have also tried to pass in the {artifacts:path} variable that is available in the receipe by adding it to a config:

 "ComponentConfiguration": {
    "DefaultConfiguration": {
      "GGV2ComponentConfig": {
        "current_version" : "0.0.123",
        "gps_tick_topic" : "gps/tick",
        "timeout_sec" : 10,
        "test_nmea_file" : "{artifacts:path}/test/route.nmea"
      },

and passing it into the python like:

  "Lifecycle": {
        "Install": "pip3 install awsiotsdk pynmeagps",
        "Run": {
          "Script": "python3 -u {artifacts:decompressedPath}/gg_gps_publish/main.py '{configuration:/GGV2ComponentConfig}'",
          "RequiresPrivilege": "false"
        }
      },

when i read the GGV2ComponentConfig.test_nmea_file configuration , the {artifacts:path} part is empty

clogwog
질문됨 2년 전329회 조회
1개 답변
1
수락된 답변

Hello,

{artifacts:path} would be the proper way to find the artifact location. You cannot use that string interpolation in the configuration however. Instead, you may pass it into your component using the command line or environment variables, for example in your recipe

lifecycle:
  run:
    script: python3 -u run_abc.py
    setEnv:
      ARTIFACT_PATH: "{artifacts:path}"
AWS
전문가
답변함 2년 전
profile picture
전문가
검토됨 10달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠