Mose
05/21/2020, 10:26 PMalex
05/21/2020, 10:29 PMSolidDefinition
, PipelineDefinition
etc so as long as those instances get wired up correctly i think it should workRepositoryDefinition
will have to be a functionMose
05/21/2020, 10:35 PMfrom dagster import execute_pipeline, pipeline, solid, DagsterType
import pandas as pd
import json
import os
class Foo:
def __init__(context, self):
self.target_sheets = {}
self.targets = None
self.target_path = r'/Users/foo/target'
self.target_sheets = self.get_sheet_config()
def get_sheet_config(self):
with open(r'config.json') as sheets:
return json.load(sheets)
def change_current_directory(self, path):
dir = os.path.join(os.path.expanduser('~'), path)
os.chdir(dir)
return dir
@solid
def check_for_targets(self, context):
<http://context.log.info|context.log.info>(f'Changing paths: {target_path}')
change_current_directory(target_path)
files = os.listdir(target_path)
<http://context.log.info|context.log.info>(f'Available files: {files}')
if len(files) > 0:
return True
<http://context.log.info|context.log.info>(f'Path and files: {target_path}, {files[0]}')
else:
return False
@solid
def check_sheet(self, context, check: bool):
if check:
try:
change_current_directory(target_path)
self.targets = pd.ExcelFile(file_name)
if sorted(list(self.targets.sheet_names)) == sorted(self.target_sheets.keys()):
return True
else:
return False
except Exception as ex:
<http://context.log.info|context.log.info>(f'Error to check {ex}')
return False
else:
<http://context.log.info|context.log.info>(f'Targets file does not exist')
return False
foo = Foo()
# dagit -f hubba_targets.py -n targets_pipeline`
@pipeline
def foo_pipeline():
foo.check_sheet(
foo.check_sheet()
)
alex
05/21/2020, 10:41 PMtargets_pipeline
@pipeline
via the CLI it will have to be a top level function
your @solid
function on the class are going to need to be @staticmethod
- we can work with instance methodsMose
05/21/2020, 10:43 PMalex
05/21/2020, 10:44 PMMose
05/21/2020, 10:44 PMalex
05/21/2020, 10:47 PMpython test.py
to make sure it evaluates correctlyMose
05/21/2020, 10:56 PMmax
05/21/2020, 11:01 PMSolidDefinition
class directly!Mose
05/21/2020, 11:03 PM