| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f2883fe commit bf22eba
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | 32 | DEFAULT_AWS_REGION_NAME = "us-east-1" | |
| 33 | 33 | LOGGER = logging.getLogger(__name__) | |
| 34 | - TIMESTAMP = "-{:%Y%m%d%H%M%S}".format(datetime.datetime.utcnow()) | ||
| 34 | + TIMESTAMP = "-{:%Y%m%d%H%M%S}".format(datetime.datetime.now(datetime.timezone.utc)) | ||
| 35 | 35 | HEAD_NODE_SUBNET_IPS = 250 | |
| 36 | 36 | ||
| 37 | 37 | if sys.version_info >= (3, 4): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | # or in the "LICENSE.txt" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES | |
| 9 | 9 | # OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions and | |
| 10 | 10 | # limitations under the License. | |
| 11 | - from datetime import datetime | ||
| 11 | + from datetime import datetime, timezone | ||
| 12 | 12 | ||
| 13 | 13 | from aws_cdk import aws_batch as batch | |
| 14 | 14 | from aws_cdk import aws_cloudformation as cfn | |
@@ -524,7 +524,7 @@ def _add_code_build_policy(self): | |||
| 524 | 524 | ) | |
| 525 | 525 | ||
| 526 | 526 | def _add_code_build_docker_image_builder_project(self): | |
| 527 | - timestamp = f"{datetime.utcnow().strftime('%Y%m%d%H%M')}" | ||
| 527 | + timestamp = f"{datetime.now(timezone.utc).strftime('%Y%m%d%H%M')}" | ||
| 528 | 528 | log_group_name = ( | |
| 529 | 529 | f"{CW_LOG_GROUP_NAME_PREFIX}codebuild/{self.stack_name}-CodeBuildDockerImageBuilderProject-{timestamp}" | |
| 530 | 530 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,7 @@ | |||
| 18 | 18 | # | |
| 19 | 19 | import json | |
| 20 | 20 | from collections import defaultdict, namedtuple | |
| 21 | - from datetime import datetime | ||
| 21 | + from datetime import datetime, timezone | ||
| 22 | 22 | from typing import Union | |
| 23 | 23 | ||
| 24 | 24 | from aws_cdk import aws_cloudformation as cfn | |
@@ -128,15 +128,15 @@ def __init__( | |||
| 128 | 128 | self._launch_template_builder = CdkLaunchTemplateBuilder() | |
| 129 | 129 | self.config = cluster_config | |
| 130 | 130 | self.bucket = bucket | |
| 131 | - self.timestamp = datetime.utcnow().strftime("%Y%m%d%H%M%S") | ||
| 131 | + self.timestamp = datetime.now(timezone.utc).strftime("%Y%m%d%H%M%S") | ||
| 132 | 132 | if self.config.is_cw_logging_enabled: | |
| 133 | 133 | if log_group_name: | |
| 134 | 134 | # pcluster update keep the log group, | |
| 135 | 135 | # It has to be passed in order to avoid the change of log group name because of the suffix. | |
| 136 | 136 | self.log_group_name = log_group_name | |
| 137 | 137 | else: | |
| 138 | 138 | # pcluster create create a log group with timestamp suffix | |
| 139 | - timestamp = f"{datetime.utcnow().strftime('%Y%m%d%H%M')}" | ||
| 139 | + timestamp = f"{datetime.now(timezone.utc).strftime('%Y%m%d%H%M')}" | ||
| 140 | 140 | self.log_group_name = f"{CW_LOG_GROUP_NAME_PREFIX}{self.stack.stack_name}-{timestamp}" | |
| 141 | 141 | ||
| 142 | 142 | self.shared_storage_infos = {storage_type: [] for storage_type in SharedStorageType} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -199,7 +199,7 @@ def to_utc_datetime(time_in, default_timezone=datetime.timezone.utc) -> datetime | |||
| 199 | 199 | if isinstance(time_in, int): | |
| 200 | 200 | if time_in > 1e12: | |
| 201 | 201 | time_in /= 1000 | |
| 202 | - time_ = datetime.datetime.utcfromtimestamp(time_in) | ||
| 202 | + time_ = datetime.datetime.fromtimestamp(time_in, tz=datetime.timezone.utc) | ||
| 203 | 203 | time_ = time_.replace(tzinfo=datetime.timezone.utc) | |
| 204 | 204 | elif isinstance(time_in, str): | |
| 205 | 205 | time_ = dateutil.parser.parse(time_in) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,7 @@ | |||
| 13 | 13 | import os | |
| 14 | 14 | import re | |
| 15 | 15 | from abc import ABC, abstractmethod | |
| 16 | - from datetime import datetime | ||
| 16 | + from datetime import datetime, timezone | ||
| 17 | 17 | from typing import Any, Dict, List | |
| 18 | 18 | ||
| 19 | 19 | import pytest | |
@@ -970,7 +970,7 @@ def test_head_node_bootstrap_timeout(mocker, config_file_name, expected_head_nod | |||
| 970 | 970 | ) | |
| 971 | 971 | assert_that( | |
| 972 | 972 | generated_template["Resources"] | |
| 973 | - .get("HeadNodeWaitCondition" + datetime.utcnow().strftime("%Y%m%d%H%M%S")) | ||
| 973 | + .get("HeadNodeWaitCondition" + datetime.now(timezone.utc).strftime("%Y%m%d%H%M%S")) | ||
| 974 | 974 | .get("Properties") | |
| 975 | 975 | .get("Timeout") | |
| 976 | 976 | ).is_equal_to(expected_head_node_bootstrap_timeout) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ def publish_compute_nodes_metric(scheduler_commands, max_monitoring_time, region | |||
| 29 | 29 | metrics_pub = MetricsPublisher(region) | |
| 30 | 30 | compute_nodes_time_series = [] | |
| 31 | 31 | ec2_nodes_time_series = [] | |
| 32 | - timestamps = [datetime.datetime.utcnow()] | ||
| 32 | + timestamps = [datetime.datetime.now(datetime.timezone.utc)] | ||
| 33 | 33 | ||
| 34 | 34 | @retry( | |
| 35 | 35 | # Retry until EC2 and Scheduler capacities scale down to 0 | |
@@ -61,7 +61,7 @@ def _watch_compute_nodes_allocation(): | |||
| 61 | 61 | ): | |
| 62 | 62 | ec2_nodes_time_series.append(ec2_instances_count) | |
| 63 | 63 | compute_nodes_time_series.append(compute_nodes) | |
| 64 | - timestamps.append(datetime.datetime.utcnow()) | ||
| 64 | + timestamps.append(datetime.datetime.now(datetime.timezone.utc)) | ||
| 65 | 65 | except Exception as e: | |
| 66 | 66 | logging.warning("Failed while watching nodes allocation with exception: %s", e) | |
| 67 | 67 | raise | |
@@ -72,7 +72,7 @@ def _watch_compute_nodes_allocation(): | |||
| 72 | 72 | # ignoring this error in order to perform assertions on the collected data. | |
| 73 | 73 | pass | |
| 74 | 74 | ||
| 75 | - end_time = datetime.datetime.utcnow() | ||
| 75 | + end_time = datetime.datetime.now(datetime.timezone.utc) | ||
| 76 | 76 | logging.info( | |
| 77 | 77 | "Monitoring completed: compute_nodes_time_series [ %s ], timestamps [ %s ]", | |
| 78 | 78 | " ".join(map(str, compute_nodes_time_series)), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,7 +47,7 @@ def test_scaling_performance( | |||
| 47 | 47 | scheduler_commands = scheduler_commands_factory(remote_command_executor) | |
| 48 | 48 | ||
| 49 | 49 | logging.info("Starting benchmark with following parameters: %s", benchmark_params) | |
| 50 | - start_time = datetime.datetime.utcnow() | ||
| 50 | + start_time = datetime.datetime.now(datetime.timezone.utc) | ||
| 51 | 51 | kwargs = {"nodes": benchmark_params["scaling_target"]} | |
| 52 | 52 | result = scheduler_commands.submit_command("sleep {0}".format(benchmark_params["job_duration"]), **kwargs) | |
| 53 | 53 | scheduler_commands.assert_job_submitted(result.stdout) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,7 +52,7 @@ def test_scheduler_performance( | |||
| 52 | 52 | scheduler_commands = scheduler_commands_factory(remote_command_executor) | |
| 53 | 53 | ||
| 54 | 54 | logging.info("Starting benchmark with following parameters: %s", benchmark_params) | |
| 55 | - start_time = datetime.datetime.utcnow() | ||
| 55 | + start_time = datetime.datetime.now(datetime.timezone.utc) | ||
| 56 | 56 | _submit_jobs(benchmark_params, scheduler_commands, cluster, scheduler_commands_factory) | |
| 57 | 57 | compute_nodes_time_series, timestamps, end_time = publish_compute_nodes_metric( | |
| 58 | 58 | scheduler_commands, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,9 +38,9 @@ def generate_cw_report(test_results_dir, namespace, aws_region, timestamp_day_st | |||
| 38 | 38 | if start_timestamp is not None: | |
| 39 | 39 | timestamp = datetime.datetime.fromtimestamp(start_timestamp) | |
| 40 | 40 | elif timestamp_day_start: | |
| 41 | - timestamp = datetime.datetime.combine(datetime.datetime.utcnow(), datetime.time()) | ||
| 41 | + timestamp = datetime.datetime.combine(datetime.datetime.now(datetime.timezone.utc), datetime.time()) | ||
| 42 | 42 | else: | |
| 43 | - timestamp = datetime.datetime.utcnow() | ||
| 43 | + timestamp = datetime.datetime.now(datetime.timezone.utc) | ||
| 44 | 44 | for category, dictionary in report.items(): | |
| 45 | 45 | if category == "all": | |
| 46 | 46 | _put_metrics(metric_pub, namespace, dictionary, [], timestamp) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -93,7 +93,9 @@ def test_fsx_lustre_configuration_options( | |||
| 93 | 93 | bucket_name = s3_bucket_factory() | |
| 94 | 94 | bucket = boto3.resource("s3", region_name=region).Bucket(bucket_name) | |
| 95 | 95 | bucket.upload_file(str(test_datadir / "s3_test_file"), "s3_test_file") | |
| 96 | - weekly_maintenance_start_time = (datetime.datetime.utcnow() + datetime.timedelta(minutes=60)).strftime("%u:%H:%M") | ||
| 96 | + weekly_maintenance_start_time = ( | ||
| 97 | + datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(minutes=60) | ||
| 98 | + ).strftime("%u:%H:%M") | ||
| 97 | 99 | cluster_config = pcluster_config_reader( | |
| 98 | 100 | bucket_name=bucket_name, | |
| 99 | 101 | mount_dir=mount_dir, | |
@@ -247,7 +249,7 @@ def test_fsx_lustre_backup(region, pcluster_config_reader, clusters_factory, sch | |||
| 247 | 249 | ||
| 248 | 250 | """ | |
| 249 | 251 | mount_dir = "/fsx_mount_dir" | |
| 250 | - daily_automatic_backup_start_time = datetime.datetime.utcnow() + datetime.timedelta(minutes=15) | ||
| 252 | + daily_automatic_backup_start_time = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(minutes=15) | ||
| 251 | 253 | logging.info(f"daily_automatic_backup_start_time: {daily_automatic_backup_start_time}") | |
| 252 | 254 | cluster_config = pcluster_config_reader( | |
| 253 | 255 | mount_dir=mount_dir, daily_automatic_backup_start_time=daily_automatic_backup_start_time.strftime("%H:%M") | |
@@ -670,7 +672,7 @@ def monitor_automatic_backup_creation(fsx_fs_id, region, backup_start_time): | |||
| 670 | 672 | def sleep_until_automatic_backup_creation_start_time(fsx_fs_id, backup_start_time): | |
| 671 | 673 | """Wait for the automatic backup of the given file system to start.""" | |
| 672 | 674 | logging.info(f"Sleeping until time when {fsx_fs_id}'s backup creation should start at {backup_start_time}") | |
| 673 | - remaining_time = (backup_start_time - datetime.datetime.utcnow()).total_seconds() | ||
| 675 | + remaining_time = (backup_start_time - datetime.datetime.now(datetime.timezone.utc)).total_seconds() | ||
| 674 | 676 | if remaining_time > 0: | |
| 675 | 677 | time.sleep(remaining_time) | |
| 676 | 678 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments