def library(name): '''Scaffolds a Dagster library <NAME> in python_modules/libraries/dagster-<NAME>. ''' template_library_path = os.path.join(ASSETS_PATH, 'dagster-library-tmpl') new_template_library_path = os.path.abspath( 'python_modules/libraries/dagster-{name}'.format(name=name)) if os.path.exists(new_template_library_path): raise click.UsageError( 'Library with name {name} already exists'.format(name=name)) copy_directory(template_library_path, new_template_library_path) version = get_most_recent_git_tag() for dname, _, files in os.walk(new_template_library_path): for fname in files: fpath = os.path.join(dname, fname) with open(fpath) as f: s = f.read() s = s.replace('{{LIBRARY_NAME}}', name) s = s.replace('{{VERSION}}', version) with open(fpath, 'w') as f: f.write(s) new_fname = fname.replace('.tmpl', '') new_fpath = os.path.join(dname, new_fname) shutil.move(fpath, new_fpath) print('Created {path}'.format(path=new_fpath)) new_dname = dname.replace('library-tmpl', name) shutil.move(dname, new_dname) print('Library created at {path}'.format(path=new_template_library_path))
def version(short): """Gets the most recent tagged version.""" dmp = DagsterModulePublisher() module_versions = dmp.check_all_versions_equal() git_tag = get_most_recent_git_tag() parsed_version = packaging.version.parse(git_tag) errors = {} for module_name, module_version in module_versions.items(): if packaging.version.parse( module_version["__version__"]) > parsed_version: errors[module_name] = module_version["__version__"] if errors: click.echo( "Warning: Found modules with existing versions that did not match the most recent " "tagged version {git_tag}:\n{versions}".format( git_tag=git_tag, versions=format_module_versions(module_versions))) else: if short: click.echo(git_tag) else: click.echo( "All modules in lockstep with most recent tagged version: {git_tag}" .format(git_tag=git_tag))
def example(name): '''Scaffolds a Dagster example in the top-level examples/ folder. ''' template_library_path = os.path.join(ASSETS_PATH, 'dagster-example-tmpl') new_template_library_path = os.path.abspath( 'examples/{name}'.format(name=name)) doc_path = os.path.abspath( './docs/next/src/pages/examples/{name}.mdx'.format(name=name)) if os.path.exists(new_template_library_path): raise click.UsageError( 'Example with name {name} already exists'.format(name=name)) if os.path.exists(doc_path): raise click.UsageError( 'Docs page already exists: {doc_path}'.format(doc_path=doc_path)) add_to_examples_json(name) copy_directory(template_library_path, new_template_library_path) version = get_most_recent_git_tag() for dname, _, files in os.walk(new_template_library_path): for fname in files: fpath = os.path.join(dname, fname) with open(fpath) as f: s = f.read() s = s.replace('{{EXAMPLE_NAME}}', name) s = s.replace('{{VERSION}}', version) with open(fpath, 'w') as f: f.write(s) new_fname = fname.replace('.tmpl', '').replace('{{EXAMPLE_NAME}}', name) new_fpath = os.path.join(dname, new_fname) shutil.move(fpath, new_fpath) print('Created {path}'.format(path=new_fpath)) new_dname = dname.replace('example-tmpl', name) shutil.move(dname, new_dname) shutil.move(os.path.join(new_template_library_path, 'README.mdx'), doc_path) print('Example created at {path}'.format(path=new_template_library_path)) print('Documentation stub created at {path}'.format(path=doc_path)) print('Added metadata to {path}'.format(path=EXAMPLES_JSON_PATH))
def library(name): """Scaffolds a Dagster library <NAME> in python_modules/libraries/dagster-<NAME>.""" template_library_path = os.path.join(ASSETS_PATH, "dagster-library-tmpl") new_template_library_path = os.path.abspath( "python_modules/libraries/dagster-{name}".format(name=name)) if os.path.exists(new_template_library_path): raise click.UsageError( "Library with name {name} already exists".format(name=name)) copy_directory(template_library_path, new_template_library_path) version = get_most_recent_git_tag() for dname, _, files in os.walk(new_template_library_path): new_dname = dname.replace("library-tmpl", name) for fname in files: fpath = os.path.join(dname, fname) with open(fpath) as f: s = f.read() s = s.replace("{{LIBRARY_NAME}}", name) s = s.replace("{{VERSION}}", version) with open(fpath, "w") as f: f.write(s) new_fname = fname.replace(".tmpl", "") new_fpath = os.path.join(dname, new_fname) shutil.move(fpath, new_fpath) print("Created {path}".format( path=os.path.join(new_dname, new_fname))) shutil.move(dname, new_dname) print("Library created at {path}".format(path=new_template_library_path))