def init(): app_properties = app_properties_from_args(args) config = galaxy.config.Configuration(**app_properties) object_store = build_object_store_from_config(config) model = init_models_from_config(config, object_store=object_store) return model, object_store
def __init__(self, config): self.object_store = build_object_store_from_config(config) # Setup the database engine and ORM self.model = init_models_from_config(config, object_store=self.object_store) registry = Registry() registry.load_datatypes() galaxy.model.set_datatypes_registry(registry)
def init(): if args.username == 'all': args.username = None if args.email == 'all': args.email = None app_properties = app_properties_from_args(args) config = galaxy.config.Configuration(**app_properties) object_store = build_object_store_from_config(config) engine = config.database_connection.split(":")[0] return init_models_from_config(config, object_store=object_store), object_store, engine
def _init(args): properties = app_properties_from_args(args) config = galaxy.config.Configuration(**properties) object_store = build_object_store_from_config(config) if not config.database_connection: logging.warning("The database connection is empty. If you are using the default value, please uncomment that in your galaxy.yml") model = init_models_from_config(config, object_store=object_store) return ( model, object_store, config, )
def main(argv): parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('-k', '--secret-key', help='Key to convert pages with', default='') parser.add_argument('-d', '--dry-run', help='No changes, just test it.', action='store_true') populate_config_args(parser) args = parser.parse_args() properties = app_properties_from_args(args) config = galaxy.config.Configuration(**properties) secret = args.secret_key or config.id_secret security_helper = IdEncodingHelper(id_secret=secret) object_store = build_object_store_from_config(config) if not config.database_connection: print( "The database connection is empty. If you are using the default value, please uncomment that in your galaxy.yml" ) model = init_models_from_config(config, object_store=object_store) session = model.context.current pagerevs = session.query(model.PageRevision).all() mock_trans = Bunch(app=Bunch(security=security_helper), model=model, user_is_admin=lambda: True, sa_session=session) for p in pagerevs: try: processor = PageContentProcessor(mock_trans, placeholderRenderForSave) processor.feed(p.content) newcontent = unicodify(processor.output(), 'utf-8') if p.content != newcontent: if not args.dry_run: p.content = unicodify(processor.output(), 'utf-8') session.add(p) session.flush() else: print("Modifying revision %s." % p.id) print(difflib.unified_diff(p.content, newcontent)) except Exception: logging.exception( "Error parsing page, rolling changes back and skipping revision %s. Please report this error." % p.id) session.rollback()
def _configure_models(self, check_migrate_databases=False, config_file=None): """Preconditions: object_store must be set on self.""" db_url = self.config.database_connection install_db_url = self.config.install_database_connection # TODO: Consider more aggressive check here that this is not the same # database file under the hood. combined_install_database = not (install_db_url and install_db_url != db_url) install_db_url = install_db_url or db_url install_database_options = self.config.database_engine_options if combined_install_database else self.config.install_database_engine_options if self.config.database_wait: self._wait_for_database(db_url) if getattr(self.config, "max_metadata_value_size", None): custom_types.MAX_METADATA_VALUE_SIZE = self.config.max_metadata_value_size if check_migrate_databases: # Initialize database / check for appropriate schema version. # If this # is a new installation, we'll restrict the tool migration messaging. create_or_verify_database( db_url, config_file, self.config.database_engine_options, app=self, map_install_models=combined_install_database) if not combined_install_database: tsi_create_or_verify_database(install_db_url, install_database_options, app=self) self.model = init_models_from_config( self.config, map_install_models=combined_install_database, object_store=self.object_store, trace_logger=getattr(self, "trace_logger", None)) if combined_install_database: log.info( "Install database targetting Galaxy's database configuration.") self.install_model = self.model else: install_db_url = self.config.install_database_connection log.info( f"Install database using its own connection {install_db_url}") self.install_model = install_mapping.init( install_db_url, install_database_options)
def main(): parser = argparse.ArgumentParser(DESCRIPTION) populate_config_args(parser) args = parser.parse_args() app_properties = app_properties_from_args(args) config = galaxy.config.Configuration(**app_properties) model = init_models_from_config(config) for row in model.context.query(model.Dataset): if row.uuid is None: row.uuid = uuid.uuid4() print("Setting dataset:", row.id, " UUID to ", row.uuid) model.context.flush() for row in model.context.query(model.Workflow): if row.uuid is None: row.uuid = uuid.uuid4() print("Setting Workflow:", row.id, " UUID to ", row.uuid) model.context.flush() print("Complete")
from galaxy.model.mapping import init_models_from_config from galaxy.security import idencoding from galaxy.util.script import app_properties_from_args, populate_config_args parser = argparse.ArgumentParser() populate_config_args(parser) parser.add_argument('-e', '--encode-id', dest='encode_id', help='Encode an ID') parser.add_argument('-d', '--decode-id', dest='decode_id', help='Decode an ID') parser.add_argument('--hda', dest='hda_id', help='Display HistoryDatasetAssociation info') parser.add_argument('--ldda', dest='ldda_id', help='Display LibraryDatasetDatasetAssociation info') args = parser.parse_args() app_properties = app_properties_from_args(args) config = galaxy.config.Configuration(**app_properties) helper = idencoding.IdEncodingHelper(id_secret=app_properties.get('id_secret')) model = init_models_from_config(config) if args.encode_id: print(f'Encoded "{args.encode_id}": {helper.encode_id(args.encode_id)}') if args.decode_id: print(f'Decoded "{args.decode_id}": {helper.decode_id(args.decode_id)}') if args.hda_id: try: hda_id = int(args.hda_id) except Exception: hda_id = int(helper.decode_id(args.hda_id)) hda = model.context.current.query(model.HistoryDatasetAssociation).get(hda_id) print(f'HDA "{hda.id}" is Dataset "{hda.dataset.id}" at: {hda.file_name}')