code stringlengths 1 18.2k |
|---|
def config_id_exists(search_id): """ Test if a build configuration matching search_id exists :param search_id: id to test for :return: True if a build configuration with search_id exists, False otherwise """ response = utils.checked_api_call(pnc_api.build_configs, 'get_specific', id=search_id) if not response: return F... |
def build(id=None, name=None, revision=None, temporary_build=False, timestamp_alignment=False, no_build_dependencies=False, keep_pod_on_failure=False, force_rebuild=False, rebuild_mode=common.REBUILD_MODES_DEFAULT): """ Trigger a BuildConfiguration by name or ID """ data = build_raw(id, name, revision, temporary_build,... |
def get_build_configuration(id=None, name=None): """ Retrieve a specific BuildConfiguration """ data = get_build_configuration_raw(id, name) if data: return utils.format_json(data) |
def update_build_configuration(id, **kwargs): """ Update an existing BuildConfiguration with new information :param id: ID of BuildConfiguration to update :param name: Name of BuildConfiguration to update :return: """ data = update_build_configuration_raw(id, **kwargs) if data: return utils.format_json(data) |
def delete_build_configuration(id=None, name=None): """ Delete an existing BuildConfiguration :param id: :param name: :return: """ data = delete_build_configuration_raw(id, name) if data: return utils.format_json(data) |
def list_build_configurations_for_product(id=None, name=None, page_size=200, page_index=0, sort="", q=""): """ List all BuildConfigurations associated with the given Product. """ data = list_build_configurations_for_product_raw(id, name, page_size, page_index, sort, q) if data: return utils.format_json_list(data) |
def list_build_configurations_for_project(id=None, name=None, page_size=200, page_index=0, sort="", q=""): """ List all BuildConfigurations associated with the given Project. """ data = list_build_configurations_for_project_raw(id, name, page_size, page_index, sort, q) if data: return utils.format_json_list(data) |
def list_build_configurations_for_product_version(product_id, version_id, page_size=200, page_index=0, sort="", q=""): """ List all BuildConfigurations associated with the given ProductVersion """ data = list_build_configurations_for_project_raw(product_id, version_id, page_size, page_index, sort, q) if data: return ut... |
def add_dependency(id=None, name=None, dependency_id=None, dependency_name=None): """ Add an existing BuildConfiguration as a dependency to another BuildConfiguration. """ data = add_dependency_raw(id, name, dependency_id, dependency_name) if data: return utils.format_json_list(data) |
def remove_dependency(id=None, name=None, dependency_id=None, dependency_name=None): """ Remove a BuildConfiguration from the dependency list of another BuildConfiguration """ data = remove_dependency_raw(id, name, dependency_id, dependency_name) if data: return utils.format_json_list(data) |
def list_product_versions_for_build_configuration(id=None, name=None, page_size=200, page_index=0, sort="", q=""): """ List all ProductVersions associated with a BuildConfiguration """ data = list_product_versions_for_build_configuration_raw(id, name, page_size, page_index, sort, q) if data: return utils.format_json_li... |
def add_product_version_to_build_configuration(id=None, name=None, product_version_id=None): """ Associate an existing ProductVersion with a BuildConfiguration """ data = remove_product_version_from_build_configuration_raw(id, name, product_version_id) if data: return utils.format_json_list(data) |
def remove_product_version_from_build_configuration(id=None, name=None, product_version_id=None): """ Remove a ProductVersion from association with a BuildConfiguration """ data = remove_product_version_from_build_configuration_raw(id, name, product_version_id) if data: return utils.format_json_list(data) |
def list_revisions_of_build_configuration(id=None, name=None, page_size=200, page_index=0, sort=""): """ List audited revisions of a BuildConfiguration """ data = list_revisions_of_build_configuration_raw(id, name, page_size, page_index, sort) if data: return utils.format_json_list(data) |
def get_revision_of_build_configuration(revision_id, id=None, name=None): """ Get a specific audited revision of a BuildConfiguration """ data = get_revision_of_build_configuration_raw(revision_id, id, name) if data: return utils.format_json_list(data) |
def list_build_configurations(page_size=200, page_index=0, sort="", q=""): """ List all BuildConfigurations """ data = list_build_configurations_raw(page_size, page_index, sort, q) if data: return utils.format_json_list(data) |
def tzabbr_register(abbr, name, region, zone, dst): """Register a new timezone abbreviation in the global registry. If another abbreviation with the same name has already been registered it new abbreviation will only be registered in region specific dictionary. """ newabbr = tzabbr() newabbr.abbr = abbr newabbr.name = ... |
def create_license(**kwargs): """ Create a new License """ License = create_license_object(**kwargs) response = utils.checked_api_call(pnc_api.licenses, 'create_new', body=License) if response: return utils.format_json(response.content) |
def get_license(id): """ Get a specific License by either ID or fullname """ response = utils.checked_api_call( pnc_api.licenses, 'get_specific', id= id) if response: return utils.format_json(response.content) |
def delete_license(license_id): """ Delete a License by ID """ response = utils.checked_api_call(pnc_api.licenses, 'delete', id=license_id) if response: return utils.format_json(response.content) |
def update_license(license_id, **kwargs): """ Replace the License with given ID with a new License """ updated_license = pnc_api.licenses.get_specific(id=license_id).content for key, value in iteritems(kwargs): if value: setattr(updated_license, key, value) response = utils.checked_api_call( pnc_api.licenses, 'update',... |
def list_licenses(page_size=200, page_index=0, sort="", q=""): """ List all Licenses """ response = utils.checked_api_call(pnc_api.licenses, 'get_all', page_size=page_size, page_index=page_index, sort=sort, q=q) if response: return utils.format_json_list(response.content) |
def transform(self, img, transformation, params): ''' Apply transformations to the image. New transformations can be defined as methods:: def do__transformationname(self, img, transformation, params): 'returns new image with transformation applied' ... def new_size__transformationname(self, size, target_size, params): ... |
def get_resizer(self, size, target_size): '''Choose a resizer depending an image size''' sw, sh = size if sw >= sh * self.rate: return self.hor_resize else: return self.vert_resize |
def add(self, song): """往播放列表末尾添加一首歌曲""" if song in self._songs: return self._songs.append(song) logger.debug('Add %s to player playlist', song) |
def insert(self, song): """在当前歌曲后插入一首歌曲""" if song in self._songs: return if self._current_song is None: self._songs.append(song) else: index = self._songs.index(self._current_song) self._songs.insert(index + 1, song) |
def remove(self, song): """Remove song from playlist. O(n) If song is current song, remove the song and play next. Otherwise, just remove it. """ if song in self._songs: if self._current_song is None: self._songs.remove(song) elif song == self._current_song: next_song = self.next_song # 随机模式下或者歌单只剩一首歌曲,下一首可能和当前歌曲相同 if ... |
def current_song(self, song): """设置当前歌曲,将歌曲加入到播放列表,并发出 song_changed 信号 .. note:: 该方法理论上只应该被 Player 对象调用。 """ self._last_song = self.current_song if song is None: self._current_song = None # add it to playlist if song not in playlist elif song in self._songs: self._current_song = song else: self.insert(song) self._curre... |
def _get_good_song(self, base=0, random_=False, direction=1): """从播放列表中获取一首可以播放的歌曲 :param base: base index :param random: random strategy or not :param direction: forward if > 0 else backword >>> pl = Playlist([1, 2, 3]) >>> pl._get_good_song() 1 >>> pl._get_good_song(base=1) 2 >>> pl._bad_songs = [2] >>> pl._get_good_... |
def next_song(self): """next song for player, calculated based on playback_mode""" # 如果没有正在播放的歌曲,找列表里面第一首能播放的 if self.current_song is None: return self._get_good_song() if self.playback_mode == PlaybackMode.random: next_song = self._get_good_song(random_=True) else: current_index = self._songs.index(self.current_song) ... |
def previous_song(self): """previous song for player to play NOTE: not the last played song """ if self.current_song is None: return self._get_good_song(base=-1, direction=-1) if self.playback_mode == PlaybackMode.random: previous_song = self._get_good_song(direction=-1) else: current_index = self._songs.index(self.cur... |
def state(self, value): """set player state, emit state changed signal outer object should not set state directly, use ``pause`` / ``resume`` / ``stop`` / ``play`` method instead. """ self._state = value self.state_changed.emit(value) |
def play_song(self, song): """播放指定歌曲 如果目标歌曲与当前歌曲不相同,则修改播放列表当前歌曲, 播放列表会发出 song_changed 信号,player 监听到信号后调用 play 方法, 到那时才会真正的播放新的歌曲。如果和当前播放歌曲相同,则忽略。 .. note:: 调用方不应该直接调用 playlist.current_song = song 来切换歌曲 """ if song is not None and song == self.current_song: logger.warning('The song is already under playing.') else: self... |
def _on_song_changed(self, song): """播放列表 current_song 发生变化后的回调 判断变化后的歌曲是否有效的,有效则播放,否则将它标记为无效歌曲。 如果变化后的歌曲是 None,则停止播放。 """ logger.debug('Player received song changed signal') if song is not None: logger.info('Try to play song: %s' % song) if song.url: self.play(song.url) else: self._playlist.mark_as_bad(song) self.play... |
def _read_managed_gavs(artifact, repo_url=None, mgmt_type=MGMT_TYPE.DEPENDENCIES, mvn_repo_local=None): """ Reads all artifacts managed in dependencyManagement section of effective pom of the given artifact. It places the repo_url in settings.xml and then runs help:effective-pom with these settings. There should be the... |
the pom pom_path = download_pom(repo_url, artifact) if pom_path: pom_dir = os.path.split(pom_path)[0] # get effective pom eff_pom = get_effective_pom(pom_dir, repo_url, mvn_repo_local) shutil.rmtree(pom_dir, True) if not eff_pom: return None # read dependencyManagement/pluginManagement section managed_arts = read_manag... |
def get_effective_pom(pom_dir, repo_url, mvn_repo_local, profiles=None, additional_params=None): """ Gets the effective pom from the downloaded pom. There has to be complete source tree (at least the pom tree) in case that the root pom contains some modules. :param pom_dir: directory where the pom is prepared (includin... |
if additional_params in effective_pom_cache[repo_url][gav][profiles].keys(): eff_pom = effective_pom_cache[repo_url][gav][profiles][additional_params] if not eff_pom: try: eff_pom = _read_effective_pom(pom_dir, repo_url, mvn_repo_local, profiles, additional_params) finally: if eff_pom: effective_pom_cache.setdefault(re... |
def alter_poms(pom_dir, additional_params, repo_url=None, mvn_repo_local=None): """ Runs mvn clean command with provided additional parameters to perform pom updates by pom-manipulation-ext. """ work_dir = os.getcwd() os.chdir(pom_dir) try: if repo_url: settings_filename = create_mirror_settings(repo_url) else: setting... |
def pom_contains_modules(): """ Reads pom.xml in current working directory and checks, if there is non-empty modules tag. """ pom_file = None try: pom_file = open("pom.xml") pom = pom_file.read() finally: if pom_file: pom_file.close() artifact = MavenArtifact(pom=pom) if artifact.modules: return True else: return False |
def get_repo_url(mead_tag, nexus_base_url, prefix="hudson-", suffix=""): """ Creates repository Nexus group URL composed of: <nexus_base_url>/content/groups/<prefix><mead_tag><suffix> :param mead_tag: name of the MEAD tag used to create the proxy URL in settings.xml :param nexus_base_url: the base URL of a Nexus instan... |
def download_pom(repo_url=None, artifact=None, pom_url=None, target_dir=None): """ Downloads a pom file with give GAV (as array) or from given pom_url and saves it as pom.xml into target_dir. :param repo_url: repository URL from which the pom should be downloaded, mandatory only if no pom_url provided :param artifact: ... |
logging.error("Failed to download POM %s. %s", pom_url, err) return None if not target_dir: num = 1 while not target_dir or os.path.exists(target_dir): target_dir = "/tmp/maven-temp-path-%s" % num num += 1 pom_path = os.path.join(target_dir, "pom.xml") if handler.getcode() == 200: pom = handler.read() handler.close() i... |
def create_mirror_settings(repo_url): """ Creates settings.xml in current working directory, which when used makes Maven use given repo URL as a mirror of all repositories to look at. :param repo_url: the repository URL to use :returns: filepath to the created file """ cwd = os.getcwd() settings_path = os.path.join(cwd... |
def search(self, s, stype=1, offset=0, total='true', limit=60): """get songs list from search keywords""" action = uri + '/search/get' data = { 's': s, 'type': stype, 'offset': offset, 'total': total, 'limit': 60 } resp = self.request('POST', action, data) if resp['code'] == 200: return resp['result']['songs'] return [... |
def artist_infos(self, artist_id): """ :param artist_id: artist_id :return: { code: int, artist: {artist}, more: boolean, hotSongs: [songs] } """ action = uri + '/artist/' + str(artist_id) data = self.request('GET', action) return data |
def album_infos(self, album_id): """ :param album_id: :return: { code: int, album: { album } } """ action = uri + '/album/' + str(album_id) data = self.request('GET', action) if data['code'] == 200: return data['album'] |
def op_music_to_playlist(self, mid, pid, op): """ :param op: add or del """ url_add = uri + '/playlist/manipulate/tracks' trackIds = '["' + str(mid) + '"]' data_add = { 'tracks': str(mid), # music id 'pid': str(pid), # playlist id 'trackIds': trackIds, # music id str 'op': op # opation } data = self.request('POST', url... |
def get_mv_detail(self, mvid): """Get mv detail :param mvid: mv id :return: """ url = uri + '/mv/detail?id=' + str(mvid) return self.request('GET', url) |
def get_lyric_by_songid(self, mid): """Get song lyric :param mid: music id :return: { lrc: { version: int, lyric: str }, tlyric: { version: int, lyric: str } sgc: bool, qfy: bool, sfy: bool, transUser: {}, code: int, } """ # tv 表示翻译。-1:表示要翻译,1:不要 url = uri + '/song/lyric?' + 'id=' + str(mid) + '&lv=1&kv=1&tv=-1' return... |
def _init_index(root_dir, schema, index_name): """ Creates new index or opens existing. Args: root_dir (str): root dir where to find or create index. schema (whoosh.fields.Schema): schema of the index to create or open. index_name (str): name of the index. Returns: tuple ((whoosh.index.FileIndex, str)): first element i... |
def reset(self): """ Resets index by removing index directory. """ if os.path.exists(self.index_dir): rmtree(self.index_dir) self.index = None |
def all(self): """ Returns list with all indexed datasets. """ datasets = [] for dataset in self.index.searcher().documents(): res = DatasetSearchResult() res.vid = dataset['vid'] res.b_score = 1 datasets.append(res) return datasets |
def search(self, search_phrase, limit=None): """ Finds datasets by search phrase. Args: search_phrase (str or unicode): limit (int, optional): how many results to return. None means without limit. Returns: list of DatasetSearchResult instances. """ query_string = self._make_query_from_terms(search_phrase) self._parsed_... |
def _make_query_from_terms(self, terms): """ Creates a query for dataset from decomposed search terms. Args: terms (dict or unicode or string): Returns: tuple: First element is str with FTS query, second is parameters of the query. """ expanded_terms = self._expand_terms(terms) cterms = '' if expanded_terms['doc']: cte... |
def _get_generic_schema(self): """ Returns whoosh's generic schema of the dataset. """ schema = Schema( vid=ID(stored=True, unique=True), # Object id title=NGRAMWORDS(), keywords=KEYWORD, # Lists of coverage identifiers, ISO time values and GVIDs, source names, source abbrev doc=TEXT) # Generated document for the core ... |
def _delete(self, vid=None): """ Deletes given dataset from index. Args: vid (str): dataset vid. """ assert vid is not None, 'vid argument can not be None.' writer = self.index.writer() writer.delete_by_term('vid', vid) writer.commit() |
def is_indexed(self, dataset): """ Returns True if dataset is already indexed. Otherwise returns False. """ with self.index.searcher() as searcher: result = searcher.search(Term('vid', dataset.vid)) return bool(result) |
def search(self, search_phrase, limit=None): """ Finds identifier by search phrase. """ self._parsed_query = search_phrase schema = self._get_generic_schema() parser = QueryParser('name', schema=schema) query = parser.parse(search_phrase) class PosSizeWeighting(scoring.WeightingModel): def scorer(self, searcher, fieldn... |
def _index_document(self, identifier, force=False): """ Adds identifier document to the index. """ writer = self.index.writer() all_names = set([x['name'] for x in self.index.searcher().documents()]) if identifier['name'] not in all_names: writer.add_document(**identifier) writer.commit() |
def _get_generic_schema(self): """ Returns whoosh's generic schema. """ schema = Schema( identifier=ID(stored=True), # Partition versioned id type=ID(stored=True), name=NGRAM(phrase=True, stored=True, minsize=2, maxsize=8)) return schema |
def _delete(self, identifier=None): """ Deletes given identifier from index. Args: identifier (str): identifier of the document to delete. """ assert identifier is not None, 'identifier argument can not be None.' writer = self.index.writer() writer.delete_by_term('identifier', identifier) writer.commit() |
def is_indexed(self, identifier): """ Returns True if identifier is already indexed. Otherwise returns False. """ with self.index.searcher() as searcher: result = searcher.search(Term('identifier', identifier['identifier'])) return bool(result) |
def all(self): """ Returns list with all indexed partitions. """ partitions = [] for partition in self.index.searcher().documents(): partitions.append( PartitionSearchResult(dataset_vid=partition['dataset_vid'], vid=partition['vid'], score=1)) return partitions |
def search(self, search_phrase, limit=None): """ Finds partitions by search phrase. Args: search_phrase (str or unicode): limit (int, optional): how many results to generate. None means without limit. Yields: PartitionSearchResult instances. """ query_string = self._make_query_from_terms(search_phrase) self._parsed_que... |
def _make_query_from_terms(self, terms): """ returns a FTS query for partition created from decomposed search terms. args: terms (dict or str): returns: str containing fts query. """ expanded_terms = self._expand_terms(terms) cterms = '' if expanded_terms['doc']: cterms = self.backend._or_join(expanded_terms['doc']) ke... |
def _from_to_as_term(self, frm, to): """ Turns from and to into the query format. Args: frm (str): from year to (str): to year Returns: FTS query str with years range. """ # The wackiness with the conversion to int and str, and adding ' ', is because there # can't be a space between the 'TO' and the brackets in the tim... |
def _index_document(self, document, force=False): """ Adds parition document to the index. """ if force: self._delete(vid=document['vid']) writer = self.index.writer() writer.add_document(**document) writer.commit() |
def copy(self, _): """ Return a copy of the SimMemory. """ #l.debug("Copying %d bytes of memory with id %s." % (len(self.mem), self.id)) c = SimSymbolicDbgMemory( mem=self.mem.branch(), memory_id=self.id, endness=self.endness, abstract_backer=self._abstract_backer, read_strategies=[ s.copy() for s in self.read_strategi... |
def column(self): """Return the ambry column""" from ambry.orm.exc import NotFoundError if not hasattr(self, 'partition'): return None if not self.name: return None try: try: return self.partition.column(self.name) except AttributeError: return self.partition.table.column(self.name) except NotFoundError: return None |
def get_handler(progname, address=None, proto=None, facility=None, fmt=None, datefmt=None, **_): """Helper function to create a Syslog handler. See `ulogger.syslog.SyslogHandlerBuilder` for arguments and supported keyword arguments. Returns: (obj): Instance of `logging.SysLogHandler` """ builder = SyslogHandlerBuilder(... |
def repository_type(self, repository_type): """ Sets the repository_type of this TargetRepositoryRest. :param repository_type: The repository_type of this TargetRepositoryRest. :type: str """ allowed_values = ["MAVEN", "NPM", "COCOA_POD", "GENERIC_PROXY"] if repository_type not in allowed_values: raise ValueError( "Inv... |
def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None): """ Custom worker for bundle operations :param inqueue: :param outqueue: :param initializer: :param initargs: :param maxtasks: :return: """ from ambry.library import new_library from ambry.run import get_runconfig import traceback assert maxta... |
new_library(get_runconfig()) library.database.close() # Maybe it is still open after the fork. library.init_debug() bundle_vid = mp_args[0] try: b = library.bundle(bundle_vid) library.logger = b.logger # So library logs to the same file as the bundle. b = b.cast_to_subclass() b.multi = True # In parent it is a number, ... |
sending result: %s" % (wrapped)) put((job, i, (False, wrapped))) |
def init_library(database_dsn, accounts_password, limited_run = False): """Child initializer, setup in Library.process_pool""" import os import signal # Have the child processes ignore the keyboard interrupt, and other signals. Instead, the parent will # catch these, and clean up the children. signal.signal(signal.SIGI... |
def build_mp(b, stage, source_name, force): """Ingest a source, using only arguments that can be pickled, for multiprocessing access""" source = b.source(source_name) with b.progress.start('build_mp',stage,message="MP build", source=source) as ps: ps.add(message='Running source {}'.format(source.name), source=source, s... |
def unify_mp(b, partition_name): """Unify all of the segment partitions for a parent partition, then run stats on the MPR file""" with b.progress.start('coalesce_mp',0,message="MP coalesce {}".format(partition_name)) as ps: r = b.unify_partition(partition_name, None, ps) return r |
def ingest_mp(b, stage, source_name, clean_files): """Ingest a source, using only arguments that can be pickled, for multiprocessing access""" source = b.source(source_name) with b.progress.start('ingest_mp',0,message="MP ingestion", source=source) as ps: r = b._ingest_source(source, ps, clean_files) return r |
def _repopulate_pool(self): """Bring the number of pool processes up to the specified number, for use after reaping workers which have exited. """ for i in range(self._processes - len(self._pool)): w = self.Process(target=self._worker_f, args=(self._inqueue, self._outqueue, self._initializer, self._initargs, self._maxt... |
def _compose(self, name, args, mkdir=True): """Get a named filesystem entry, and extend it into a path with additional path arguments""" from os.path import normpath from ambry.dbexceptions import ConfigurationError root = p = self._config.filesystem[name].format(root=self._root) if args: args = [e.strip() for e in arg... |
def compose(self, name, *args): """Compose, but don't create base directory""" return self._compose(name, args, mkdir=False) |
def database_dsn(self): """Substitute the root dir into the database DSN, for Sqlite""" if not self._config.library.database: return 'sqlite:///{root}/library.db'.format(root=self._root) return self._config.library.database.format(root=self._root) |
def make_table_map(table, headers): """Create a function to map from rows with the structure of the headers to the structure of the table.""" header_parts = {} for i, h in enumerate(headers): header_parts[h] = 'row[{}]'.format(i) body_code = 'lambda row: [{}]'.format(','.join(header_parts.get(c.name, 'None') for c in t... |
def augment_pipeline(pl, head_pipe=None, tail_pipe=None): """ Augment the pipeline by adding a new pipe section to each stage that has one or more pipes. Can be used for debugging :param pl: :param DebugPipe: :return: """ for k, v in iteritems(pl): if v and len(v) > 0: if head_pipe and k != 'source': # Can't put anythi... |
def _to_ascii(s): """ Converts given string to ascii ignoring non ascii. Args: s (text or binary): Returns: str: """ # TODO: Always use unicode within ambry. from six import text_type, binary_type if isinstance(s, text_type): ascii_ = s.encode('ascii', 'ignore') elif isinstance(s, binary_type): ascii_ = s.decode('utf-8... |
def report_progress(self): """ This function can be called from a higher level to report progress. It is usually called from an alarm signal handler which is installed just before starting an operation: :return: Tuple: (process description, #records, #total records, #rate) """ from time import time # rows, rate = pl.si... |
def parse(v): """ Parse a slice string, of the same form as used by __getitem__ >>> Slice.parse("2:3,7,10:12") :param v: Input string :return: A list of tuples, one for each element of the slice string """ parts = v.split(',') slices = [] for part in parts: p = part.split(':') if len(p) == 1: slices.append(int(p[0])) e... |
def process_header(self, headers): """Ignore the incomming header and replace it with the destination header""" return [c.name for c in self.source.dest_table.columns][1:] |
def mangle_column_name(self, i, n): """ Override this method to change the way that column names from the source are altered to become column names in the schema. This method is called from :py:meth:`mangle_header` for each column in the header, and :py:meth:`mangle_header` is called from the RowGenerator, so it will a... |
def init(self): """Deferred initialization b/c the object con be constructed without a valid source""" from itertools import chain def maybe_int(v): try: return int(v) except ValueError: return None if not self.initialized: self.data_start_line = 1 self.data_end_line = None self.header_lines = [0] if self.source.start_... |
def rate(self): """Report the insertion rate in records per second""" end = self._end_time if self._end_time else time.time() return self._count / (end - self._start_time) |
def _subset(self, subset): """Return a new pipeline with a subset of the sections""" pl = Pipeline(bundle=self.bundle) for group_name, pl_segment in iteritems(self): if group_name not in subset: continue pl[group_name] = pl_segment return pl |
def configure(self, pipe_config): """Configure from a dict""" # Create a context for evaluating the code for each pipeline. This removes the need # to qualify the class names with the module import ambry.etl import sys # ambry.build comes from ambry.bundle.files.PythonSourceFile#import_bundle eval_locals = dict(list(lo... |
of Bundle methods to call afer the pipeline # completes super(Pipeline, self).__setattr__('final', pipes) elif segment_name == 'replace': for frm, to in iteritems(pipes): self.replace(eval_pipe(frm), eval_pipe(to)) else: # Check if any of the pipes have a location command. If not, the pipe # is cleared and the set of p... |
to the segment self[segment_name].append(ep) elif location == '-': # Prepend to the segment self[segment_name].prepend(ep) elif location == '!': # Replace a pipe of the same class if isinstance(ep, type): repl_class = ep else: repl_class = ep.__class__ self.replace(repl_class, ep, segment_name) |
def replace(self, repl_class, replacement, target_segment_name=None): """Replace a pipe segment, specified by its class, with another segment""" for segment_name, pipes in iteritems(self): if target_segment_name and segment_name != target_segment_name: raise Exception() repl_pipes = [] found = False for pipe in pipes: ... |
def install(self, connection, partition, table_name=None, columns=None, materialize=False, logger=None): """ Creates FDW or materialize view for given partition. Args: connection: connection to postgresql partition (orm.Partition): materialize (boolean): if True, create read-only table. If False create virtual table. R... |
IF NOT EXISTS {} AS SELECT * FROM {} ".format(partition.vid, final_table) cursor.execute(view_q) cursor.execute('COMMIT;') return partition.vid |
def index(self, connection, partition, columns): """ Create an index on the columns. Args: connection: partition (orm.Partition): columns (list of str): """ query_tmpl = 'CREATE INDEX ON {table_name} ({column});' table_name = '{}_v'.format(partition.vid) for column in columns: query = query_tmpl.format(table_name=table... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.