Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 40f56e57

Přidáno uživatelem Eliška Mourycová před více než 3 roky(ů)

Re #8942. Implemented data and help commands.

Zobrazit rozdíly:

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