Sourcery refactored master branch#1
Conversation
| cmd = 'rmdir /S /Q "{}"' | ||
| else: | ||
| cmd = 'rm -r "{}"' | ||
| cmd = 'rmdir /S /Q "{}"' if (platform.system() == "Windows") else 'rm -r "{}"' |
There was a problem hiding this comment.
Function Helper.delete_dir refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| if '__main__' == __name__: | ||
| if __name__ == '__main__': |
There was a problem hiding this comment.
Lines 154-154 refactored with the following changes:
- Ensure constant in comparison is on the right (
flip-comparison)
| ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE CODE, EVEN IF ADVISED OF THE | ||
| POSSIBILITY OF SUCH DAMAGE. | ||
| """ | ||
|
|
There was a problem hiding this comment.
Lines 73-136 refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Replace call to format with f-string [×2] (
use-fstring-for-formatting) - Move setting of default value for variable into
elsebranch (introduce-default-else) - Replace if statement with if expression (
assign-if-exp)
|
|
||
| # load the model | ||
| print("Loading model from " + model_path) | ||
| print(f"Loading model from {model_path}") |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| "run_id": run_id, | ||
| "experiment_name": exp.name} | ||
| tagsValue.update(model_tags) | ||
| tagsValue |= model_tags |
There was a problem hiding this comment.
Function register_aml_model refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union) - Replace call to format with f-string (
use-fstring-for-formatting)
| pipeline_id_string = "##vso[task.setvariable variable=pipeline_id;isOutput=true]{}".format( # NOQA: E501 | ||
| published_pipeline.id | ||
| ) | ||
| pipeline_id_string = f"##vso[task.setvariable variable=pipeline_id;isOutput=true]{published_pipeline.id}" |
There was a problem hiding this comment.
Function build_batchscore_pipeline refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| 'Could not find CSV dataset at "%s". If you have bootstrapped your project, you will need to provide a CSV.' # NOQA: E501 | ||
| % file_name | ||
| ) # NOQA: E501 | ||
| f'Could not find CSV dataset at "{file_name}". If you have bootstrapped your project, you will need to provide a CSV.' | ||
| ) |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| name=e.pipeline_name + "_with_R_on_DB", | ||
| name=f"{e.pipeline_name}_with_R_on_DB", | ||
| description="Model training/retraining pipeline", | ||
| version=e.build_id | ||
| version=e.build_id, |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| raise Exception( | ||
| "No pipeline found matching name:{}".format(env.scoring_pipeline_name) # NOQA: E501 | ||
| ) | ||
| raise Exception(f"No pipeline found matching name:{env.scoring_pipeline_name}") |
There was a problem hiding this comment.
Function get_pipeline refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
This removes the following comments ( why? ):
# NOQA: E501
| accounturl = "https://{}.blob.core.windows.net".format( | ||
| env.scoring_datastore_storage_name | ||
| accounturl = ( | ||
| f"https://{env.scoring_datastore_storage_name}.blob.core.windows.net" | ||
| ) | ||
|
|
||
| srcblobname = "azureml/{}/{}_out/parallel_run_step.txt".format( | ||
| step_id, env.scoring_datastore_storage_name | ||
| ) | ||
| srcblobname = f"azureml/{step_id}/{env.scoring_datastore_storage_name}_out/parallel_run_step.txt" | ||
|
|
||
| srcbloburl = "{}/{}/{}".format( | ||
| accounturl, env.scoring_datastore_output_container, srcblobname | ||
| srcbloburl = ( | ||
| f"{accounturl}/{env.scoring_datastore_output_container}/{srcblobname}" |
There was a problem hiding this comment.
Function copy_output refactored with the following changes:
- Replace call to format with f-string [×4] (
use-fstring-for-formatting)
| print("Error: {}".format(ex)) | ||
| print(f"Error: {ex}") |
There was a problem hiding this comment.
Function run_batchscore_pipeline refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| if(len(matched_pipes) > 1): | ||
| if (len(matched_pipes) > 1): | ||
| published_pipeline = None | ||
| raise Exception(f"Multiple active pipelines are published for build {e.build_id}.") # NOQA: E501 | ||
| elif(len(matched_pipes) == 0): | ||
| elif not matched_pipes: |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Swap positions of nested conditionals [×2] (
swap-nested-ifs) - Simplify sequence length comparison (
simplify-len-comparison)
| compute_target = workspace.compute_targets[compute_name] | ||
| if compute_target and type(compute_target) is AmlCompute: | ||
| print("Found existing compute target " + compute_name + " so using it.") # NOQA | ||
| print(f"Found existing compute target {compute_name} so using it.") |
There was a problem hiding this comment.
Function get_compute refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
This removes the following comments ( why? ):
# NOQA
| print("Package stored at {} with build log {}".format(package.location, package.package_build_log_uri)) # NOQA: E501 | ||
| print( | ||
| f"Package stored at {package.location} with build log {package.package_build_log_uri}" | ||
| ) | ||
|
|
||
| # Save the Image Location for other AzDO jobs after script is complete | ||
| if args.output_image_location_file is not None: | ||
| print("Writing image location to %s" % args.output_image_location_file) | ||
| print(f"Writing image location to {args.output_image_location_file}") |
There was a problem hiding this comment.
Lines 53-57 refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| headers['Authorization'] = 'Bearer ' + service_keys[0] | ||
| headers['Authorization'] = f'Bearer {service_keys[0]}' | ||
| print("Testing service") | ||
| print(". url: %s" % service.scoring_uri) | ||
| output = call_web_app(service.scoring_uri, headers) | ||
|
|
||
| return output | ||
| print(f". url: {service.scoring_uri}") | ||
| return call_web_app(service.scoring_uri, headers) |
There was a problem hiding this comment.
Function call_web_service refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation) - Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run:Help us improve this pull request!