Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 40f56e57

Přidáno uživatelem Eliška Mourycová před téměř 4 roky(ů)

Re #8942. Implemented data and help commands.

Zobrazit rozdíly:

Server/ServerApp/DataDownload/DataDownloader.cs
336 336
			bool firstLoop = true;
337 337
			do
338 338
			{
339
				Console.WriteLine("current date: " + currentDate);
339
				//Console.WriteLine("current date: " + currentDate);
340 340
				savedFiles.AddRange(DownloadData(type, format, (int)currentDate.Year, (int)currentDate.Month));
341 341
				Date nextDate = currentDate.IncreaseMonthByOne();
342 342

  
Server/ServerApp/Program.cs
25 25
    public class Program
26 26
    {
27 27

  
28
		public void NotifyUserMessage(string message)
29
		{
30
			Console.WriteLine("Received user message: " + message);
31
		}
28
		//public void NotifyUserMessage(string message)
29
		//{
30
		//	Console.WriteLine("Received user message: " + message);
31
		//}
32 32

  
33 33
        static void Main(string[] args)
34 34
        {
......
42 42
				return;
43 43
			}
44 44

  
45
			//ConsoleForamtingTest();
46

  
45 47
			
46 48

  
47 49

  
......
90 92
			Console.ReadLine();
91 93
        }
92 94

  
95
		private static void ConsoleForamtingTest()
96
		{
97

  
98
			Console.WriteLine("List of available commands and their description: ");
99
			Console.WriteLine("--------------------------------------------------");
100
			// data
101
			Console.WriteLine("data [OPTION] [DATE]...");
102
			Console.WriteLine("   Description: Capable of showing saved data files and downloading new ones.");
103
			Console.WriteLine("   -list: Lists currently saved data files. This list does not have to match the files which any of the predictors is trained on!");
104
			Console.WriteLine("      Example: data -list");
105
			Console.WriteLine("   -dl [startDate] [endDate]: Downloads jis, login and weather files from a specified time span. Both [startDate] and [endDate] are inclusive. Date format must be entered as [month]-[year].");
106
			Console.WriteLine("      Example: data -dl 1-2019 12-2020");
107
			Console.WriteLine("");
108

  
109
			// model
110
			Console.WriteLine("model [OPTION]");
111
			Console.WriteLine("   Description: Capable of retraining the prediction model, going back to the previous version and listing files on which the predictor was trained. ");
112
			Console.WriteLine("   -files: Lists the data files on which the currently used model was trained.");
113
			Console.WriteLine("      Example: model -files");
114
			Console.WriteLine("   -retrain: Retrains the model using the files currently saved in the data directory.");
115
			Console.WriteLine("      Example: model -retrain");
116
			Console.WriteLine("   -rollback: Switches the model back to the previous version.");
117
			Console.WriteLine("      Example: model -rollback");
118
		}
93 119

  
94 120
		private static DataDownloader DataDownloadAndRetrievalTest(Config config)
95 121
		{
Server/ServerApp/User/CommandsAcceptor.cs
1
using ServerApp.DataDownload;
1
//
2
//	Author: Eliska Mourycova
3
//
4

  
5
using ServerApp.DataDownload;
2 6
using ServerApp.Predictor;
3 7
using System;
4 8
using System.Collections.Generic;
......
91 95
			if(c.WholeCommand.Equals("data -list"))
92 96
			{
93 97
				Console.WriteLine("Listing all downloaded data files...");
94
				
98

  
99
				var subdirs = dd.DataSubDirectories.Values.ToArray();
100

  
101
				foreach (string sub in subdirs)
102
				{
103
					List<string> files = dd.GetData(sub, null, null);
104
					foreach (string f in files)
105
					{
106
						Console.WriteLine(f);
107
					}
108
				}
95 109
			}
96 110
			else if (c.FlagsAndData.ContainsKey("dl"))
97 111
			{
......
107 121

  
108 122
				if (start == null || end == null)
109 123
				{
110
					Console.WriteLine("Date parsing was not successful. Please ensure you enter the dates in the following format: 1-2020. Month must be greater than zero.");
124
					Console.WriteLine("Date parsing was not successful. Please ensure you enter the dates in the following format: [month]-[year] (e.g. 1-2020). Month must be greater than zero.");
111 125
					return;
112 126
				}
113 127

  
114
				Console.WriteLine("Downloading data from " + start.ToString() + " to " + end.ToString());
128
				Console.WriteLine("Downloading jis, login and weather data from " + start.ToString() + " to " + end.ToString() + "...");
129

  
130
				try
131
				{
132
					List<string> files = dd.DownloadData(DataType.JIS, DataFormat.CSV, start, end);
133
					files.AddRange(dd.DownloadData(DataType.STROJE, DataFormat.CSV, start, end));
134
					files.AddRange(dd.DownloadData(DataType.POCASI, DataFormat.CSV, start, end));
135

  
136
					Console.WriteLine("Data download complete, saved files: ");
137
					foreach (string f in files)
138
						Console.WriteLine(f);
139

  
140
				}
141
				catch(Exception ex)
142
				{
143
					Console.WriteLine("Data download failed, please ensure the start date is before or same as end date.");
144
					return;
145
				}
146
				
147
				
115 148
			}
116 149
		}
117 150

  
118 151
		private void HandleModelCommand(Command c)
119 152
		{
153
			// TODO:
120 154
			// model -files
121 155
			// model -retrain
122 156
			// model -rollback
......
124 158

  
125 159
		private void HandleHelpCommand(Command c)
126 160
		{
127
			Console.WriteLine("help.");
161
			Console.WriteLine("List of available commands and their description: ");
162
			Console.WriteLine("--------------------------------------------------");
163
			// data
164
			Console.WriteLine("data [OPTION] [DATE]...");
165
			Console.WriteLine("   Description: Capable of showing saved data files and downloading new ones.");
166
			Console.WriteLine("   -list: Lists currently saved data files. This list does not have to match the files which any of the predictors is trained on!");
167
			Console.WriteLine("      Example: data -list");
168
			Console.WriteLine("   -dl [startDate] [endDate]: Downloads jis, login and weather files from a specified time span. Both [startDate] and [endDate] are inclusive. Date format must be entered as [month]-[year].");
169
			Console.WriteLine("      Example: data -dl 1-2019 12-2020");
170
			Console.WriteLine("");
171

  
172
			// model
173
			Console.WriteLine("model [OPTION]");
174
			Console.WriteLine("   Description: Capable of retraining the prediction model, going back to the previous version and listing files on which the predictor was trained. ");
175
			Console.WriteLine("   -files: Lists the data files on which the currently used model was trained.");
176
			Console.WriteLine("      Example: model -files");
177
			Console.WriteLine("   -retrain: Retrains the model using the files currently saved in the data directory.");
178
			Console.WriteLine("      Example: model -retrain");
179
			Console.WriteLine("   -rollback: Switches the model back to the previous version.");
180
			Console.WriteLine("      Example: model -rollback");
128 181
		}
129 182

  
130 183
		private void PrintUsage(Command c)

Také k dispozici: Unified diff