Best Python code snippet using pyatom_python
assets.py
Source:assets.py
...25 """26 # concurrentMap could easily support a timeout if we want to add a blanket T.O.27 outcomes = concurrentMap(localizeAsset, assets)28 if any(map(lambda oc: isinstance(oc, Failure), outcomes)):29 logFailures(outcomes, assets)30 # Clean up the successful downloads31 consume(filterMapSucceeded(lambda p: Path(p).unlink(), outcomes))32 return Failure(track("Unable to localize one or more assets"))33 else:34 return Success(list(map(lambda oc: oc.value, outcomes)))35def logFailures(outcomes:Sequence[Outcome[str, pathlike]], assets:Sequence[Asset]) -> None:36 for oc, nm in zip(outcomes, map(str, assets)):37 for reason in onFailure(oc):38 logging.fatal("Fatal error localizing {}: {}".format(nm, reason))39def localizeAsset(asset:Asset) -> Outcome[str, pathlike]:40 """Localize a single Asset41 """42 tempname = genUniqueAssetName(asset)43 return ( localizeAssetTyped(asset, tempname) >>44 (lambda name: decompressIfRequired(name, asset)) >>45 (lambda name: renameToLocalTarget(name, asset)) )46# These localizeAssetTyped patterns *must* return Success(target) if all47# went well. (That allows easier composition and chaining.) We start with48# a fake method so we can selectively attach new @addpattern versions to it49# based on available imports....
configValidate.py
Source:configValidate.py
1# This file is part of daf_butler.2#3# Developed for the LSST Data Management System.4# This product includes software developed by the LSST Project5# (http://www.lsst.org).6# See the COPYRIGHT file at the top-level directory of this distribution7# for details of code ownership.8#9# This program is free software: you can redistribute it and/or modify10# it under the terms of the GNU General Public License as published by11# the Free Software Foundation, either version 3 of the License, or12# (at your option) any later version.13#14# This program is distributed in the hope that it will be useful,15# but WITHOUT ANY WARRANTY; without even the implied warranty of16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the17# GNU General Public License for more details.18#19# You should have received a copy of the GNU General Public License20# along with this program. If not, see <http://www.gnu.org/licenses/>.21from .. import Butler, ValidationError22def configValidate(repo, quiet, dataset_type, ignore):23 """Validate the configuration files for a Gen3 Butler repository.24 Parameters25 ----------26 repo : `str`27 URI to the location to create the repo.28 quiet : `bool`29 Do not report individual failures if True.30 dataset_type : [`str`]31 Specific DatasetTypes to validate.32 ignore : [`str`]33 "DatasetTypes to ignore for validation."34 Returns35 -------36 is_good : `bool`37 `True` if validation was okay. `False` if there was a validation38 error.39 """40 logFailures = not quiet41 butler = Butler(config=repo)42 is_good = True43 try:44 butler.validateConfiguration(logFailures=logFailures, datasetTypeNames=dataset_type, ignore=ignore)45 except ValidationError:46 is_good = False47 else:48 print("No problems encountered with configuration.")...
invocation_logging.py
Source:invocation_logging.py
1import sys2def loggingDecorator(file=sys.stderr, logInvocations=True, logResults=False, logFailures=True):3 def actualDecorator(func):4 def wrappedFunc(*args, **kwargs):5 invocation_cmd = ['Invoke', func.__name__]6 if len(args) > 0:7 invocation_cmd += ['args:', args]8 if len(kwargs) > 0:9 invocation_cmd += ['with kwargs:', kwargs]10 try:11 if logInvocations:12 print(*invocation_cmd, file = file)13 result = func(*args, **kwargs)14 if logResults:15 print('Result: `{}`'.format(result), file = file)16 return result17 except Exception as exception:18 if logFailures:19 if not logInvocations: # if invocation not yet printed, print it now20 print(*invocation_cmd, file = file)21 print('Raised', exception, file = file)22 raise23 wrappedFunc.__name__ = "logged:{}".format(func.__name__)24 return wrappedFunc...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!