How to use artifacts_dir method in yandex-tank

Best Python code snippet using yandex-tank

mlflow_classifier.py

Source:mlflow_classifier.py Github

copy

Full Screen

1import os2import copy3import mlflow4import pandas as pd5from keras.callbacks import CSVLogger6from snsdl.keras.wrappers import BaseWrapper7class MlflowClassifier(BaseWrapper):8 """ Implementation of the mlflow classifier API for Keras using generators."""9 def __init__(self, build_fn, train_generator, test_generator, val_generator=None, tracking_server=None, artifacts_dir=None, **sk_params):10 _sk_params = copy.deepcopy(sk_params)11 self.artifacts_dir = artifacts_dir12 if artifacts_dir is not None:13 # Logs training logs in a csv file14 try:15 _sk_params['callbacks']16 except KeyError:17 _sk_params['callbacks'] = []18 finally:19 os.makedirs(os.path.join(artifacts_dir, 'text'), exist_ok=True)20 _sk_params['callbacks'].append(CSVLogger(os.path.join(artifacts_dir, 'text', 'training_log.csv')))21 # Initialize superclass parameters first22 super(MlflowClassifier, self).__init__(build_fn, train_generator, test_generator, val_generator, **_sk_params)23 # We don't want to force people to have tracking server24 # running on localhost as it tracks in mlruns directory25 if tracking_server is not None:26 # Tracking URI27 if not tracking_server.startswith("http"):28 mlflow_tracking_uri = 'http://' + tracking_server + ':5000'29 else:30 mlflow_tracking_uri = tracking_server31 # Set the Tracking URI32 mlflow.set_tracking_uri(mlflow_tracking_uri)33 print("MLflow Tracking URI: %s" % mlflow_tracking_uri)34 else:35 print("MLflow Tracking URI: %s" % "local directory 'mlruns'")36 def log(self, experiment_id=None):37 if experiment_id is not None:38 mlflow.set_experiment(experiment_id)39 training_log = None40 if os.path.isfile(os.path.join(self.artifacts_dir, 'text', 'training_log.csv')):41 training_log = pd.read_csv(os.path.join(self.artifacts_dir, 'text', 'training_log.csv'))42 # Create a pretty training log file43 f = open(os.path.join(self.artifacts_dir, 'text', 'training_log.txt'), 'w')44 f.write(training_log.to_string())45 f.close()46 # training_log = training_log.to_dict()47 with mlflow.start_run():48 # print out current run_uuid49 run_uuid = mlflow.active_run().info.run_uuid50 print("MLflow Run ID: %s" % run_uuid)51 # log parameters52 params = self.get_params()53 for k, v in params.items():54 if k not in ['build_fn', 'callbacks']:55 mlflow.log_param(k, v)56 # Log artifacts57 if self.artifacts_dir is not None:58 mlflow.log_artifacts(self.artifacts_dir, "results")59 # Get the training, validation and testing metrics60 metrics = self.getMetricsValues()61 # Log metrics62 if metrics is not None:63 for k, v in metrics.items():64 mlflow.log_metric(k, v)65 # log model66 # mlflow.keras.log_model(self.get_model(), "models")67 # # save model locally68 # pathdir = "keras_models/" + run_uuid69 # model_dir = self.get_directory_path(pathdir, False)70 # ktrain_cls.keras_save_model(model, model_dir)71 # # Write out TensorFlow events as a run artifact72 # print("Uploading TensorFlow events as a run artifact.")73 # mlflow.log_artifacts(output_dir, artifact_path="events")...

Full Screen

Full Screen

tests.py

Source:tests.py Github

copy

Full Screen

1import os2import shutil3from unittest import TestCase4import pandoc_run_filter as prf5DIR = os.path.dirname(os.path.realpath(__file__))6FLAGS = '--from=markdown --standalone --self-contained'7FILTERS = '--filter pandoc-run-filter'8ODIR = './__pandoc_run__'9ARGS = f'''{FLAGS} {FILTERS} --to epub3 --metadata title=Test -o {ODIR}/'''10class Tests(TestCase):11 def rm_file(self, path):12 if os.path.isfile(path):13 os.unlink(path)14 def rm_dir(self, path):15 if os.path.isdir(path):16 shutil.rmtree(path)17 '''Verify pandoc-run-filter is in path'''18 def test_001(self):19 self.assertIsNotNone(shutil.which('pandoc-run-filter'))20 '''Verify pandoc is in path'''21 def test_002(self):22 self.assertIsNotNone(shutil.which('pandoc'))23 '''Verify artifacts directory gets created'''24 def test_003(self):25 self.rm_dir(prf.ARTIFACTS_DIR)26 prf.initialize()27 rc = os.path.isdir(prf.ARTIFACTS_DIR)28 self.rm_dir(prf.ARTIFACTS_DIR)29 self.assertTrue(rc)30 '''Verify debug file is created'''31 def test_004(self):32 self.rm_dir(prf.ARTIFACTS_DIR)33 prf.initialize()34 prf.debug('Some debug message.')35 rc = os.path.isfile(prf.DEBUG_FILE)36 if rc == True:37 with open(prf.DEBUG_FILE) as fd:38 content = fd.read().strip()39 rc = content == 'Some debug message.'40 self.rm_dir(prf.ARTIFACTS_DIR)41 self.assertTrue(rc)42 '''Verify in="shell" out="text"'''43 def test_01(self):44 t = '01'45 cmd = f'''pandoc -i {t}.md {ARGS}/{t}.epub'''46 path = f'''{prf.ARTIFACTS_DIR}/{t}.epub'''47 os.chdir(DIR)48 if os.path.isfile(path):49 os.unlink(path)50 rc = os.system(cmd)51 if 0 == rc:52 rc = os.path.isfile(path)53 else:54 rc = False55 self.assertTrue(rc)56 '''Verify in="shell" out="image"'''57 def test_02(self):58 t = '02'59 cmd = f'''pandoc -i {t}.md {ARGS}/{t}.epub'''60 path = f'''{prf.ARTIFACTS_DIR}/{t}.epub'''61 os.chdir(DIR)62 if os.path.isfile(path):63 os.unlink(path)64 rc = os.system(cmd)65 if 0 == rc:66 rc = os.path.isfile(path)67 else:68 rc = False69 self.assertTrue(rc)70 '''Verify in="script" out="text"'''71 def test_03(self):72 t = '03'73 cmd = f'''pandoc -i {t}.md {ARGS}/{t}.epub'''74 path = f'''{prf.ARTIFACTS_DIR}/{t}.epub'''75 os.chdir(DIR)76 if os.path.isfile(path):77 os.unlink(path)78 rc = os.system(cmd)79 if 0 == rc:80 rc = os.path.isfile(path)81 else:82 rc = False83 self.assertTrue(rc)84 '''Verify in="script" out="image img="04.png"'''85 def test_04(self):86 t = '04'87 cmd = f'''pandoc -i {t}.md {ARGS}/{t}.epub'''88 path = f'''{prf.ARTIFACTS_DIR}/{t}.epub'''89 os.chdir(DIR)90 if os.path.isfile(path):91 os.unlink(path)92 rc = os.system(cmd)93 if 0 == rc:94 rc = os.path.isfile(path)95 else:96 rc = False...

Full Screen

Full Screen

p4c.in

Source:p4c.in Github

copy

Full Screen

1#!/usr/bin/env python22#3# Copyright 2013-present Barefoot Networks, Inc.4#5# Licensed under the Apache License, Version 2.0 (the "License");6# you may not use this file except in compliance with the License.7# You may obtain a copy of the License at8#9# http://www.apache.org/licenses/LICENSE-2.010#11# Unless required by applicable law or agreed to in writing, software12# distributed under the License is distributed on an "AS IS" BASIS,13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14# See the License for the specific language governing permissions and15# limitations under the License.16import os17import sys18# p4c is supposed to work in two environments:19# - installed mode: in ${prefix}/bin, with artifacts in ${datadir}/p4c/*20# - developer mode: in the build dir with artifacts rooted also in the build dir21install_dir = os.path.abspath(os.path.dirname(sys.argv[0]))22if not os.path.exists(os.path.join(install_dir, 'p4c_src')):23 # this is the installed configuration24 build_type = "INSTALLED"25 artifacts_dir = '@datarootdir@'26 if artifacts_dir == '${prefix}/share':27 # datadir based on prefix28 if '@exec_prefix@' != '${prefix}':29 bin2prefix = os.path.relpath('@prefix@', '@exec_prefix@/bin')30 else:31 bin2prefix = '..'32 artifacts_dir = os.path.normpath(os.path.join(install_dir, bin2prefix, "share/p4c"))33 else:34 # explicit datadir. add package name35 artifacts_dir = os.path.join(artifacts_dir, 'p4c')36else:37 build_type = "DEVELOPER"38 artifacts_dir = install_dir39sys.path.insert(1, artifacts_dir)40os.environ['P4C_BUILD_TYPE'] = build_type41os.environ['P4C_BIN_DIR'] = install_dir42os.environ['P4C_CFG_PATH'] = os.path.join(artifacts_dir, "p4c_src")43os.environ['P4C_16_INCLUDE_PATH'] = os.path.join(artifacts_dir, "p4include")44os.environ['P4C_14_INCLUDE_PATH'] = os.path.join(artifacts_dir, "p4_14include")45from p4c_src.main import main46from p4c_src.main import set_version47set_version("@P4C_VERSION@")48if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful