cryptobiu / MATRIX

MPC Simulation Framework
MIT License
24 stars 13 forks source link

Date calculations #10

Closed lenerd closed 6 years ago

lenerd commented 6 years ago

Hi,

the following calculations with a datetime object are problematic:

https://github.com/cryptobiu/MATRIX/blob/77a331626027cc4c7c4855aff8fe640ecde15e69/Deployment/aws_deploy.py#L92-L94

In case the current hour is at most 2 or at least 21 the first or second replace will fail, respectively (see below). Instead of replacing the hour part of the datetime object, a timedelta should be used.

I do not understand the purpose of the first subtraction of three hours. (If this tries to convert UTC+3 to UTC, then there are better ways to achieve this.)

Welcome to MATRIX system.
Please Insert your choice:
1. Deploy Menu
2. Execute Menu
3. Analysis Menu
4. Generate Circuits
5. Exit
Your choice:1
Enter configuration file(s):
Configuration file path (current path is: /path/to/MATRIX): ProtocolsConfigurations/Config_BMR.json
Choose cloud provider:
1. AWS
2. Scaleway
Your choice:1
Choose deployment task
1. Deploy Instance(s)
2. Create Key pair(s)
3. Create security group(s)
4. Get instances network data
5. Terminate machines
6. Change machines types
7. Start instances 
8. Stop instances
Your choice:1
Current date : 
2018-09-13 20:51:24.636319
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/path/to/MATRIX/main.py in <module>()
    169 
    170 if __name__ == '__main__':
--> 171     main()

/path/to/MATRIX/main.py in main()
    157 
    158             if selection == '1':
--> 159                 print_instances_management_menu(conf_file_path)
    160 
    161             elif selection == '2':

/path/to/MATRIX/main.py in print_instances_management_menu(conf_file_path)
     52 
     53         if selection == '1':
---> 54             deploy.deploy_instances()
     55         elif selection == '2':
     56             deploy.create_key_pair()

/path/to/MATRIX/Deployment/aws_deploy.py in deploy_instances(self)
     92             date = datetime.now().replace(hour=datetime.now().hour - 3)
     93             print('Current date : \n%s' % str(date))
---> 94             new_date = date.replace(hour=date.hour + 6)
     95 
     96             for idx in range(len(regions)):

ValueError: hour must be in 0..23
> /path/to/MATRIX/Deployment/aws_deploy.py(94)deploy_instances()
     92             date = datetime.now().replace(hour=datetime.now().hour - 3)
     93             print('Current date : \n%s' % str(date))
---> 94             new_date = date.replace(hour=date.hour + 6)
     95 
     96             for idx in range(len(regions)):

ipdb> date.hour
20