Skip to content

Commit

Permalink
upgrade to pachyderm_sdk for github action. Add li191r and parQuantum…
Browse files Browse the repository at this point in the history
…Line
  • Loading branch information
covesturtevant committed Nov 6, 2023
1 parent c3370c0 commit ec01627
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 101 deletions.
58 changes: 58 additions & 0 deletions .github/workflow_scripts/put_files/put_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from pachyderm_sdk import Client
from pachyderm_sdk.api import pfs, pps
import environs
from urllib.parse import urlparse
from pathlib import Path
import os

def setup_client(pachd_address:str, pach_token:str):

# Example of how to create a robot token with the required permissions
# pachctl auth get-robot-token testrunner
# pachctl auth set project default repoOwner robot:testrunner

pach_url = urlparse(pachd_address)
host = pach_url.hostname
port = pach_url.port
if port is None:
port = 80
if pach_url.scheme == "https" or pach_url.scheme == "grpcs":
tls = True
else:
tls = False
return Client(host=host, port=port, tls=tls, auth_token=pach_token)


def main():
env = environs.Env()
pachd_address = os.environ["PACHD_ADDRESS"] # e.g. "grpcs://pachd.nonprod.gcp.neoninternal.org:443"
pach_token = os.environ["PACH_TOKEN"] # auth token (string). Needs repoOwner roles
repo_name = os.environ["REPO"] # The Pachyderm repo (e.g. "empty_files_prt")
branch_name = os.environ["BRANCH"] # The branch of the pachyderm repo (e.g. "master")
in_path = os.environ["IN_PATH"] # The local path to the folder that will be uploaded into pachyderm (e.g. "empty_files/prt"")
out_path = os.environ["OUT_PATH"] # The path where the folder will be placed in the pachydemr repo (e.g. "prt")

# Setup connection to Pachyderm
client = setup_client(pachd_address,pach_token)

# If the repo does not exist, create it and create the desired branch
repo = pfs.Repo.from_uri(repo_name)
try:
client.pfs.create_repo(repo=repo)
except:
print(f'Did not create repo:',repo_name,' (likely already exists)')# Log the warning

# Put the updated file(s) into Pachyderm
branch = pfs.Branch.from_uri(repo_name+"@"+branch_name)
if Path(in_path).is_dir():
with client.pfs.commit(branch=branch) as commit:
client.pfs.put_files(commit=commit,source=in_path,path=out_path)
else:
with client.pfs.commit(branch=branch) as commit:
with open(in_path, "rb") as source:
client.pfs.put_file_from_file(commit=commit,path=out_path,file=source,append=False)

if __name__ == "__main__":
main()


4 changes: 4 additions & 0 deletions .github/workflow_scripts/put_files/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Python 3.10
pachyderm_sdk
certifi
environs
15 changes: 0 additions & 15 deletions .github/workflow_scripts/put_folder/Dockerfile

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflow_scripts/put_folder/put_folder.py

This file was deleted.

3 changes: 0 additions & 3 deletions .github/workflow_scripts/put_folder/requirements.txt

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/li191r_avro_schemas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: li191r-avro-schemas
on:
push:
branches:
- 'master'
paths:
- 'avro_schemas/li191r/**'
workflow_dispatch: {} # Allows trigger of workflow from web interface
jobs:
put-file:
runs-on: arc-neon-gke
#runs-on: ubuntu-latest
env:
PACHD_ADDRESS: grpcs://pachyderm-dev.transitions-nonprod.gcp.neoninternal.org:443
PACH_TOKEN: ${{ secrets.RepoOwnerPachydermDev }}
REPO: li191r_avro_schemas # Pachyderm repo
BRANCH: master
IN_PATH: 'avro_schemas/li191r' # Single path to local file or directory. If directory, all files in directory will be place in pachyderm at OUT_PATH.
OUT_PATH: '/li191r' # Path to place the file(s) in Pachyderm. If IN_PATH is a file, specify to the file. If IN_PATH is a directory, specify to the directory.
steps:
- uses: actions/checkout@v4
- run: ls -la

- uses: actions/setup-python@v3
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
cache: 'pip'
- run: pip install -r .github/workflow_scripts/put_files/requirements.txt
- run: python3 -u .github/workflow_scripts/put_files/put_files.py
29 changes: 29 additions & 0 deletions .github/workflows/li191r_empty_files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: li191r-empty-files
on:
push:
branches:
- 'master'
paths:
- 'empty_files/li191r/**'
workflow_dispatch: {} # Allows trigger of workflow from web interface
jobs:
put-file:
runs-on: arc-neon-gke
#runs-on: ubuntu-latest
env:
PACHD_ADDRESS: grpcs://pachyderm-dev.transitions-nonprod.gcp.neoninternal.org:443
PACH_TOKEN: ${{ secrets.RepoOwnerPachydermDev }}
REPO: li191r_empty_files # Pachyderm repo
BRANCH: master
IN_PATH: 'empty_files/li191r' # Single path to local file or directory. If directory, all files in directory will be place in pachyderm at OUT_PATH.
OUT_PATH: '/li191r' # Path to place the file(s) in Pachyderm. If IN_PATH is a file, specify to the file. If IN_PATH is a directory, specify to the directory.
steps:
- uses: actions/checkout@v4
- run: ls -la

- uses: actions/setup-python@v3
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
cache: 'pip'
- run: pip install -r .github/workflow_scripts/put_files/requirements.txt
- run: python3 -u .github/workflow_scripts/put_files/put_files.py
29 changes: 29 additions & 0 deletions .github/workflows/parQuantumLine_avro_schemas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: parQuantumLine-avro-schemas
on:
push:
branches:
- 'master'
paths:
- 'avro_schemas/parQuantumLine/**'
workflow_dispatch: {} # Allows trigger of workflow from web interface
jobs:
put-file:
runs-on: arc-neon-gke
#runs-on: ubuntu-latest
env:
PACHD_ADDRESS: grpcs://pachyderm-dev.transitions-nonprod.gcp.neoninternal.org:443
PACH_TOKEN: ${{ secrets.RepoOwnerPachydermDev }}
REPO: parQuantumLine_avro_schemas # Pachyderm repo
BRANCH: master
IN_PATH: 'avro_schemas/parQuantumLine' # Single path to local file or directory. If directory, all files in directory will be place in pachyderm at OUT_PATH.
OUT_PATH: '/parQuantumLine' # Path to place the file(s) in Pachyderm. If IN_PATH is a file, specify to the file. If IN_PATH is a directory, specify to the directory.
steps:
- uses: actions/checkout@v4
- run: ls -la

- uses: actions/setup-python@v3
with:
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax
cache: 'pip'
- run: pip install -r .github/workflow_scripts/put_files/requirements.txt
- run: python3 -u .github/workflow_scripts/put_files/put_files.py
26 changes: 0 additions & 26 deletions .github/workflows/put_avro_schemas_prt.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/put_empty_files_prt.yml

This file was deleted.

0 comments on commit ec01627

Please sign in to comment.