#Python SDK and GitHub Actions

1 messages ยท Page 1 of 1 (latest)

minor field
#

Hi, sorry for the stupid question but is there any guideline on how to run the pipeline in GitHub actions?

I created the pipeline.yml in github workflows but it is not working (i need to run script pipeline.py):

name: good-ci-cd

on:
  push:
    # Trigger this workflow only on commits pushed to the main branch
    branches:
      - main

jobs:
  dagger:
    runs-on: ubuntu-latest
    steps:
      - name: Clone repository
        uses: actions/checkout@v2

      # You need to run `dagger-cue project init` locally before and commit the cue.mod directory to the repository with its contents
      - name: Run provisioning
        uses: dagger/dagger-for-github@v3
        # See all options at https://github.com/dagger/dagger-for-github
        with:
          version: 0.2
          # To pin external dependencies, you can use `project update github.com/[package-source]@v[n]`
          cmds: |
            project update
            do pipeline
        env:
          GOODDATA_HOST: ${{ secrets.GOODDATA_HOST }}
          GOODDATA_TOKEN: ${{ secrets.GOODDATA_TOKEN }}
          GOODDATA_STAGING_WORKSPACE_ID: ${{ secrets.GOODDATA_STAGING_WORKSPACE_ID }}
          GOODDATA_PRODUCTION_WORKSPACE_ID: ${{ secrets.GOODDATA_PRODUCTION_WORKSPACE_ID }}
light totem
#

Hi! Your question says "Python SDK" but you're trying to use the previous version of dagger (v0.2, with CUE). Which is it?

#

I think I remember you from somewhere... maybe twitter? ๐Ÿ™‚

minor field
#

Sorry, my bad.

Basically, I need to run my pipeline:

"""
Execute a command
"""

import sys
import anyio
import dagger
import gooddata_sdk
from gooddata_sdk.catalog.workspace.entity_model.workspace import CatalogWorkspace
import os


async def pipeline():
    config = dagger.Config(log_output=sys.stderr)

    async with dagger.Connection(config):
        host = os.getenv('GOODDATA_HOST')
        token = os.getenv('GOODDATA_TOKEN')
        staging_workspace_id = os.getenv('GOODDATA_STAGING_WORKSPACE_ID')
        production_workspace_id = os.getenv('GOODDATA_PRODUCTION_WORKSPACE_ID')

        sdk = gooddata_sdk.GoodDataSdk.create(host, token)

        sdk.catalog_workspace.create_or_update(
            CatalogWorkspace(production_workspace_id, production_workspace_id)
        )

        declarative_ldm = sdk.catalog_workspace_content.get_declarative_ldm(staging_workspace_id)
        declarative_analytics_model = sdk.catalog_workspace_content.get_declarative_analytics_model(
            staging_workspace_id
        )

        sdk.catalog_workspace_content.put_declarative_ldm(
            production_workspace_id,
            declarative_ldm
        )
        sdk.catalog_workspace_content.put_declarative_analytics_model(
            production_workspace_id,
            declarative_analytics_model
        )

        print("done")


if __name__ == "__main__":
    anyio.run(pipeline)
#

Yes, maybe twitter or I created GitHub issue which you reacted to ๐Ÿ˜„

light totem
#

Ah ๐Ÿ˜„

#

Then just run your python build.py from there.

#

       - name: Set up Python
         uses: actions/setup-python@v4
         with:
           python-version: 3.10
minor field
#

Nice, it is more simple than I thought! Thanks for reply! ๐Ÿ™‚

light totem
#

Yeah! ๐Ÿ˜„

minor field
#

Have you been discussing adding this to the documentation? ๐Ÿ™‚

light totem
#

Yeah, @fair chasm can fill you in on that. I think we want to have examples for every SDK in every major CI. But the basic idea is the same. For an SDK just run an action using that SDK's language, then run your script. It's the same with node or Go, no matter the CI.

minor field
#

Cool, thanks for info ๐Ÿ™‚

light totem
#

Python's instructions are commented because the author is working it out, but you get the idea.

#

You can ignore the macos and go stuff.

minor field
light totem
#

Awesome! ๐ŸŽ‰

#

You don't need the pip install cattrs==22.2.0.

#

I notice your pipeline isn't running anything on dagger.

#

Next step?

fair chasm