aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSonja Galovic <galovicsonja@gmail.com>2022-04-18 00:20:50 +0200
committerSonja Galovic <galovicsonja@gmail.com>2022-04-18 00:20:50 +0200
commitfbf1a64ae46148754a2ca76170591b243fb8426e (patch)
tree89b76899724d9d4c0031cd2f3ee09b3b409f33c2
parent07b11e07fc62d9ea9765595812ab68209be99a3a (diff)
parentc3cc4c680bed2d2d00743bc03e6dc01501f90e25 (diff)
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into dev
-rw-r--r--backend/api/api/Controllers/DatasetController.cs76
-rw-r--r--backend/api/api/Controllers/ModelController.cs69
-rw-r--r--backend/api/api/Controllers/PredictorController.cs55
-rw-r--r--backend/api/api/Models/Dataset.cs2
-rw-r--r--backend/api/api/Models/Model.cs2
-rw-r--r--backend/api/api/Models/Predictor.cs2
-rw-r--r--backend/api/api/Services/DatasetService.cs28
-rw-r--r--backend/api/api/Services/IDatasetService.cs12
-rw-r--r--backend/api/api/Services/IModelService.cs10
-rw-r--r--backend/api/api/Services/IPredictorService.cs8
-rw-r--r--backend/api/api/Services/MlConnectionService.cs2
-rw-r--r--backend/api/api/Services/ModelService.cs22
-rw-r--r--backend/api/api/Services/PredictorService.cs16
-rw-r--r--backend/api/api/Services/TempRemovalService.cs6
-rw-r--r--backend/api/api/Services/UserService.cs12
-rw-r--r--backend/microservice/api/newmlservice.py85
-rw-r--r--frontend/src/app/_data/Notification.ts1
-rw-r--r--frontend/src/app/_elements/model-load/model-load.component.html48
-rw-r--r--frontend/src/app/_elements/model-load/model-load.component.ts5
-rw-r--r--frontend/src/app/_elements/notifications/notifications.component.html16
-rw-r--r--frontend/src/app/_elements/notifications/notifications.component.ts26
-rw-r--r--frontend/src/app/app-routing.module.ts2
22 files changed, 265 insertions, 240 deletions
diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs
index add85aba..bdac9ed9 100644
--- a/backend/api/api/Controllers/DatasetController.cs
+++ b/backend/api/api/Controllers/DatasetController.cs
@@ -25,22 +25,23 @@ namespace api.Controllers
_fileService = fileService;
jwtToken = Token;
}
- public string getUsername()
+
+ public string getUserId()
{
- string username;
+ string userId;
var header = Request.Headers[HeaderNames.Authorization];
if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
{
var scheme = headerValue.Scheme;
var parameter = headerValue.Parameter;
- username = jwtToken.TokenToUsername(parameter);
- if (username == null)
+ userId = jwtToken.TokenToId(parameter);
+ if (userId == null)
return null;
}
else
return null;
- return username;
+ return userId;
}
// GET: api/<DatasetController>/mydatasets
@@ -48,17 +49,17 @@ namespace api.Controllers
[Authorize(Roles = "User,Guest")]
public ActionResult<List<Dataset>> Get()
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- if (username == "")
+ if (userId == "")
return _datasetService.GetGuestDatasets();
//ako bude trebao ID, samo iz baze uzeti
- return _datasetService.GetMyDatasets(username);
+ return _datasetService.GetMyDatasets(userId);
}
// GET: api/<DatasetController>/datesort/{ascdsc}/{latest}
@@ -69,12 +70,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Dataset>> SortDatasets(bool ascdsc, int latest)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- List<Dataset> lista = _datasetService.SortDatasets(username, ascdsc, latest);
+ List<Dataset> lista = _datasetService.SortDatasets(userId, ascdsc, latest);
if (latest == 0)
return lista;
@@ -100,14 +101,7 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Dataset>> Search(string name)
{
- string username = getUsername();
-
- if (username == null)
- return BadRequest();
-
- //ako bude trebao ID, samo iz baze uzeti
-
- return _datasetService.SearchDatasets(name, username);
+ return _datasetService.SearchDatasets(name);
}
@@ -117,12 +111,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<Dataset> Get(string name)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var dataset = _datasetService.GetOneDataset(username, name);
+ var dataset = _datasetService.GetOneDataset(userId, name);
if (dataset == null)
return NotFound($"Dataset with name = {name} not found or dataset is not public or not preprocessed");
@@ -134,22 +128,12 @@ namespace api.Controllers
[Authorize(Roles = "User,Guest")]
public async Task<ActionResult<Dataset>> Post([FromBody] Dataset dataset)
{
- string uploaderId;
- var header = Request.Headers[HeaderNames.Authorization];
- if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
- {
- var scheme = headerValue.Scheme;
- var parameter = headerValue.Parameter;
- uploaderId = jwtToken.TokenToId(parameter);
- if (uploaderId == null)
- return null;
- }
- else
- return BadRequest();
+ string uploaderId = getUserId();
+
//da li ce preko tokena da se ubaci username ili front salje
//dataset.username = usernameToken;
//username = "" ako je GUEST DODAO
- var existingDataset = _datasetService.GetOneDataset(dataset.username, dataset.name);
+ var existingDataset = _datasetService.GetOneDataset(dataset.uploaderId, dataset.name);
if (existingDataset != null)
return NotFound($"Dateset with name = {dataset.name} exisits");
@@ -169,20 +153,20 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Put(string name, [FromBody] Dataset dataset)
{
- string username = getUsername();
+ string uploaderId = getUserId();
- if (username == null)
+ if (uploaderId == null)
return BadRequest();
- var existingDataset = _datasetService.GetOneDataset(username, name);
+ var existingDataset = _datasetService.GetOneDataset(uploaderId, name);
//ne mora da se proverava
if (existingDataset == null)
- return NotFound($"Dataset with name = {name} or user with username = {username} not found");
+ return NotFound($"Dataset with name = {name} or user with ID = {uploaderId} not found");
dataset.lastUpdated = DateTime.UtcNow;
- _datasetService.Update(username, name, dataset);
+ _datasetService.Update(uploaderId, name, dataset);
return Ok($"Dataset with name = {name} updated");
}
@@ -192,17 +176,17 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Delete(string name)
{
- string username = getUsername();
+ string uploaderId = getUserId();
- if (username == null)
+ if (uploaderId == null)
return BadRequest();
- var dataset = _datasetService.GetOneDataset(username, name);
+ var dataset = _datasetService.GetOneDataset(uploaderId, name);
if (dataset == null)
- return NotFound($"Dataset with name = {name} or user with username = {username} not found");
+ return NotFound($"Dataset with name = {name} or user with ID = {uploaderId} not found");
- _datasetService.Delete(dataset.username, dataset.name);
+ _datasetService.Delete(dataset.uploaderId, dataset.name);
return Ok($"Dataset with name = {name} deleted");
diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs
index 04c072da..1ec01ab8 100644
--- a/backend/api/api/Controllers/ModelController.cs
+++ b/backend/api/api/Controllers/ModelController.cs
@@ -56,23 +56,6 @@ namespace api.Controllers
return uploaderId;
}
- public string getUsername()
- {
- string username;
- var header = Request.Headers[HeaderNames.Authorization];
- if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
- {
- var scheme = headerValue.Scheme;
- var parameter = headerValue.Parameter;
- username = jwtToken.TokenToUsername(parameter);
- if (username == null)
- return null;
- }
- else
- return null;
-
- return username;
- }
[HttpPost("trainModel")]
[Authorize(Roles = "User,Guest")]
@@ -81,16 +64,16 @@ namespace api.Controllers
string experimentId = trainModelObject.ExperimentId;
string modelId = trainModelObject.ModelId;
- string uploaderId = getUserId();
+ string userId = getUserId();
- if (uploaderId == null)
+ if (userId == null)
return BadRequest();
var experiment=_experimentService.Get(experimentId);
var dataset = _datasetService.GetOneDataset(experiment.datasetId);
- var filepath = _fileService.GetFilePath(dataset.fileId, uploaderId);
+ var filepath = _fileService.GetFilePath(dataset.fileId, userId);
var model = _modelService.GetOneModel(modelId);
- _mlService.TrainModel(model,experiment,filepath,dataset,uploaderId);//To do Obavestiti korisnika kada se model istrenira
+ _mlService.TrainModel(model,experiment,filepath,dataset, userId);//To do Obavestiti korisnika kada se model istrenira
return Ok();
}
@@ -99,7 +82,7 @@ namespace api.Controllers
{
var model=_modelService.GetOneModel(info.ModelId);
- var user = _userService.GetUserByUsername(model.username);
+ var user = _userService.GetUserByUsername(model.uploaderId);
if (ChatHub.CheckUser(user._id))
await _ichat.Clients.Client(ChatHub.Users[user._id]).SendAsync("NotifyEpoch",model.name,info.ModelId,info.Stat,model.epochs,info.EpochNum);
@@ -117,12 +100,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Model>> Get()
{
- string username = getUsername();
-
- if (username == null)
+ string uploaderId = getUserId();
+
+ if (uploaderId == null)
return BadRequest();
- return _modelService.GetMyModels(username);
+ return _modelService.GetMyModels(uploaderId);
}
// vraca svoj model prema nekom imenu
@@ -131,12 +114,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<Model> Get(string name)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var model = _modelService.GetOneModel(username, name);
+ var model = _modelService.GetOneModel(userId, name);
if (model == null)
return NotFound($"Model with name = {name} not found");
@@ -155,14 +138,14 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Model>> GetLatestModels(int latest)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
//ako bude trebao ID, samo iz baze uzeti
- List<Model> lista = _modelService.GetLatestModels(username);
+ List<Model> lista = _modelService.GetLatestModels(userId);
List<Model> novaLista = new List<Model>();
@@ -185,7 +168,7 @@ namespace api.Controllers
/*if (_modelService.CheckHyperparameters(1, model.hiddenLayerNeurons, model.hiddenLayers, model.outputNeurons) == false)
return BadRequest("Bad parameters!");*/
- var existingModel = _modelService.GetOneModel(model.username, model.name);
+ var existingModel = _modelService.GetOneModel(model.uploaderId, model.name);
if (existingModel != null && !overwrite)
return NotFound($"Model with name = {model.name} exisits");
@@ -209,18 +192,18 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Put(string name, [FromBody] Model model)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var existingModel = _modelService.GetOneModel(username, name);
+ var existingModel = _modelService.GetOneModel(userId, name);
if (existingModel == null)
- return NotFound($"Model with name = {name} or user with username = {username} not found");
+ return NotFound($"Model with name = {name} or user with ID = {userId} not found");
- _modelService.Update(username, name, model);
+ _modelService.Update(userId, name, model);
return NoContent();
}
@@ -229,17 +212,17 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Delete(string name)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- var model = _modelService.GetOneModel(username, name);
+ var model = _modelService.GetOneModel(userId, name);
if (model == null)
- return NotFound($"Model with name = {name} or user with username = {username} not found");
+ return NotFound($"Model with name = {name} or user with ID = {userId} not found");
- _modelService.Delete(model.username, model.name);
+ _modelService.Delete(model.uploaderId, model.name);
return Ok($"Model with name = {name} deleted");
diff --git a/backend/api/api/Controllers/PredictorController.cs b/backend/api/api/Controllers/PredictorController.cs
index 64907dac..26fe8f1d 100644
--- a/backend/api/api/Controllers/PredictorController.cs
+++ b/backend/api/api/Controllers/PredictorController.cs
@@ -32,22 +32,22 @@ namespace api.Controllers
_modelService = modelService;
}
- public string getUsername()
+ public string getUserId()
{
- string username;
+ string uploaderId;
var header = Request.Headers[HeaderNames.Authorization];
if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
{
var scheme = headerValue.Scheme;
var parameter = headerValue.Parameter;
- username = jwtToken.TokenToUsername(parameter);
- if (username == null)
+ uploaderId = jwtToken.TokenToId(parameter);
+ if (uploaderId == null)
return null;
}
else
return null;
- return username;
+ return uploaderId;
}
// GET: api/<PredictorController>/mypredictors
@@ -55,12 +55,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Predictor>> Get()
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- return _predictorService.GetMyPredictors(username);
+ return _predictorService.GetMyPredictors(userId);
}
// GET: api/<PredictorController>/publicpredictors
@@ -90,12 +90,12 @@ namespace api.Controllers
[Authorize(Roles = "User,Guest")]
public ActionResult<Predictor> GetPredictor(string id)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- Predictor predictor = _predictorService.GetPredictor(username, id);
+ Predictor predictor = _predictorService.GetPredictor(userId, id);
if (predictor == null)
return NotFound($"Predictor with id = {id} not found");
@@ -108,11 +108,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<Predictor> Get(string id)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
+ //treba userId da se salje GetOnePredictor
var predictor = _predictorService.GetOnePredictor(id);
if (predictor == null)
@@ -130,12 +131,12 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult<List<Predictor>> SortPredictors(bool ascdsc, int latest)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- List<Predictor> lista = _predictorService.SortPredictors(username, ascdsc, latest);
+ List<Predictor> lista = _predictorService.SortPredictors(userId, ascdsc, latest);
if(latest == 0)
return lista;
@@ -154,7 +155,7 @@ namespace api.Controllers
[HttpPost("add")]
public async Task<ActionResult<Predictor>> Post([FromBody] Predictor predictor)
{
- var user=_userService.GetUserByUsername(predictor.username);
+ var user=_userService.GetUserById(predictor.uploaderId);
predictor.dateCreated = DateTime.Now.ToUniversalTime();
var model = _modelService.GetOneModel(predictor.modelId);
if (model == null || user==null)
@@ -171,12 +172,12 @@ namespace api.Controllers
[Authorize(Roles = "User,Guest")]
public async Task<ActionResult> UsePredictor(String id, [FromBody] PredictorColumns[] inputs)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
- Predictor predictor = _predictorService.GetPredictor(username, id);
+ Predictor predictor = _predictorService.GetPredictor(userId, id);
Experiment e = _experimentService.Get(predictor.experimentId);
@@ -195,16 +196,16 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Put(string id, [FromBody] Predictor predictor)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
var existingPredictor = _predictorService.GetOnePredictor(id);
//ne mora da se proverava
if (existingPredictor == null)
- return NotFound($"Predictor with id = {id} or user with username = {username} not found");
+ return NotFound($"Predictor with id = {id} or user with ID = {userId} not found");
_predictorService.Update(id, predictor);
@@ -216,17 +217,17 @@ namespace api.Controllers
[Authorize(Roles = "User")]
public ActionResult Delete(string id)
{
- string username = getUsername();
+ string userId = getUserId();
- if (username == null)
+ if (userId == null)
return BadRequest();
var predictor = _predictorService.GetOnePredictor(id);
if (predictor == null)
- return NotFound($"Predictor with id = {id} or user with username = {username} not found");
+ return NotFound($"Predictor with id = {id} or user with ID = {userId} not found");
- _predictorService.Delete(id);
+ _predictorService.Delete(id, userId);
return Ok($"Predictor with id = {id} deleted");
diff --git a/backend/api/api/Models/Dataset.cs b/backend/api/api/Models/Dataset.cs
index 47814449..cc7185f0 100644
--- a/backend/api/api/Models/Dataset.cs
+++ b/backend/api/api/Models/Dataset.cs
@@ -7,7 +7,7 @@ namespace api.Models
public class Dataset
{
public Dataset() { }
- public string username { get; set; }
+ public string uploaderId { get; set; }
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net
diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs
index 72ee093b..a9dbfbdd 100644
--- a/backend/api/api/Models/Model.cs
+++ b/backend/api/api/Models/Model.cs
@@ -9,7 +9,7 @@ namespace api.Models
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net
public string _id { get; set; }
- public string username { get; set; }
+ public string uploaderId { get; set; }
public string name { get; set; }
diff --git a/backend/api/api/Models/Predictor.cs b/backend/api/api/Models/Predictor.cs
index 26371d2a..8608d766 100644
--- a/backend/api/api/Models/Predictor.cs
+++ b/backend/api/api/Models/Predictor.cs
@@ -9,7 +9,7 @@ namespace api.Models
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]//mongo data type to .net
public string _id { get; set; }
- public string username { get; set; }
+ public string uploaderId { get; set; }
//public string name { get; set; }
//public string description { get; set; }
public string[] inputs { get; set; }
diff --git a/backend/api/api/Services/DatasetService.cs b/backend/api/api/Services/DatasetService.cs
index 176ab424..33026687 100644
--- a/backend/api/api/Services/DatasetService.cs
+++ b/backend/api/api/Services/DatasetService.cs
@@ -14,7 +14,7 @@ namespace api.Services
_dataset = database.GetCollection<Dataset>(settings.DatasetCollectionName);
}
- public List<Dataset> SearchDatasets(string name, string username)
+ public List<Dataset> SearchDatasets(string name)
{
return _dataset.Find(dataset => dataset.name == name && dataset.isPublic == true && dataset.isPreProcess).ToList();
}
@@ -27,27 +27,27 @@ namespace api.Services
}
//brisanje odredjenog name-a
- public void Delete(string username, string name)
+ public void Delete(string userId, string name)
{
- _dataset.DeleteOne(dataset => (dataset.username == username && dataset.name == name));
+ _dataset.DeleteOne(dataset => (dataset.uploaderId == userId && dataset.name == name));
}
- public List<Dataset> GetMyDatasets(string username)
+ public List<Dataset> GetMyDatasets(string userId)
{
- return _dataset.Find(dataset => dataset.username == username && dataset.isPreProcess).ToList();
+ return _dataset.Find(dataset => dataset.uploaderId == userId && dataset.isPreProcess).ToList();
}
public List<Dataset> GetGuestDatasets()
{
//Join Igranonica public datasetove sa svim temp uploadanim datasetovima
- List<Dataset> datasets= _dataset.Find(dataset => dataset.username == "Igrannonica" && dataset.isPublic == true && dataset.isPreProcess).ToList();
- datasets.AddRange(_dataset.Find(dataset => dataset.username == "" && dataset.isPreProcess).ToList());
+ List<Dataset> datasets= _dataset.Find(dataset => dataset.uploaderId == "Igrannonica" && dataset.isPublic == true && dataset.isPreProcess).ToList();
+ datasets.AddRange(_dataset.Find(dataset => dataset.uploaderId == "" && dataset.isPreProcess).ToList());
return datasets;
}
//poslednji datasetovi
- public List<Dataset> SortDatasets(string username, bool ascdsc, int latest)
+ public List<Dataset> SortDatasets(string userId, bool ascdsc, int latest)
{
- List<Dataset> list = _dataset.Find(dataset => dataset.username == username && dataset.isPreProcess).ToList();
+ List<Dataset> list = _dataset.Find(dataset => dataset.uploaderId == userId && dataset.isPreProcess).ToList();
if(ascdsc)
list = list.OrderBy(dataset => dataset.lastUpdated).ToList();
@@ -62,9 +62,9 @@ namespace api.Services
return _dataset.Find(dataset => dataset.isPublic == true && dataset.isPreProcess).ToList();
}
- public Dataset GetOneDataset(string username, string name)
+ public Dataset GetOneDataset(string userId, string name)
{
- return _dataset.Find(dataset => dataset.username == username && dataset.name == name && dataset.isPreProcess).FirstOrDefault();
+ return _dataset.Find(dataset => dataset.uploaderId == userId && dataset.name == name && dataset.isPreProcess).FirstOrDefault();
}
//odraditi za pretragu getOne
@@ -74,9 +74,9 @@ namespace api.Services
}
//ako je potrebno da se zameni name ili ekstenzija
- public void Update(string username, string name, Dataset dataset )
+ public void Update(string userId, string name, Dataset dataset )
{
- _dataset.ReplaceOne(dataset => dataset.username == username && dataset.name == name, dataset);
+ _dataset.ReplaceOne(dataset => dataset.uploaderId == userId && dataset.name == name, dataset);
}
public void Update(Dataset dataset)
{
@@ -85,7 +85,7 @@ namespace api.Services
public string GetDatasetId(string fileId)
{
- Dataset dataset = _dataset.Find(dataset => dataset.fileId == fileId && dataset.username == "Igrannonica").FirstOrDefault();
+ Dataset dataset = _dataset.Find(dataset => dataset.fileId == fileId && dataset.uploaderId == "Igrannonica").FirstOrDefault();
return dataset._id;
}
diff --git a/backend/api/api/Services/IDatasetService.cs b/backend/api/api/Services/IDatasetService.cs
index c6138943..b700e87c 100644
--- a/backend/api/api/Services/IDatasetService.cs
+++ b/backend/api/api/Services/IDatasetService.cs
@@ -5,15 +5,15 @@ namespace api.Services
{
public interface IDatasetService
{
- Dataset GetOneDataset(string username, string name);
+ Dataset GetOneDataset(string userId, string name);
Dataset GetOneDataset(string id);
- List<Dataset> SearchDatasets(string name, string username);
- List<Dataset> GetMyDatasets(string username);
- List<Dataset> SortDatasets(string username, bool ascdsc, int latest);
+ List<Dataset> SearchDatasets(string name);
+ List<Dataset> GetMyDatasets(string userId);
+ List<Dataset> SortDatasets(string userId, bool ascdsc, int latest);
List<Dataset> GetPublicDatasets();
Dataset Create(Dataset dataset);
- void Update(string username, string name, Dataset dataset);
- void Delete(string username, string name);
+ void Update(string userId, string name, Dataset dataset);
+ void Delete(string userId, string name);
public List<Dataset> GetGuestDatasets();
public void Update(Dataset dataset);
string GetDatasetId(string fileId);
diff --git a/backend/api/api/Services/IModelService.cs b/backend/api/api/Services/IModelService.cs
index e10b8f3b..bcb82e2d 100644
--- a/backend/api/api/Services/IModelService.cs
+++ b/backend/api/api/Services/IModelService.cs
@@ -5,16 +5,16 @@ namespace api.Services
{
public interface IModelService
{
- Model GetOneModel(string username, string name);
+ Model GetOneModel(string userId, string name);
Model GetOneModel(string id);
- List<Model> GetMyModels(string username);
- List<Model> GetLatestModels(string username);
+ List<Model> GetMyModels(string userId);
+ List<Model> GetLatestModels(string userId);
//List<Model> GetPublicModels();
Model Create(Model model);
Model Replace(Model model);
- void Update(string username, string name, Model model);
+ void Update(string userId, string name, Model model);
public void Update(string id, Model model);
- void Delete(string username, string name);
+ void Delete(string userId, string name);
bool CheckHyperparameters(int inputNeurons, int hiddenLayerNeurons, int hiddenLayers, int outputNeurons);
bool CheckDb();
}
diff --git a/backend/api/api/Services/IPredictorService.cs b/backend/api/api/Services/IPredictorService.cs
index 7c31215e..16f0432a 100644
--- a/backend/api/api/Services/IPredictorService.cs
+++ b/backend/api/api/Services/IPredictorService.cs
@@ -5,12 +5,12 @@ namespace api.Services
public interface IPredictorService
{
Predictor Create(Predictor predictor);
- void Delete(string id);
- List<Predictor> GetMyPredictors(string username);
+ void Delete(string id, string userId);
+ List<Predictor> GetMyPredictors(string userId);
Predictor GetOnePredictor(string id);
- Predictor GetPredictor(string username, string id);
+ Predictor GetPredictor(string userId, string id);
List<Predictor> GetPublicPredictors();
- List<Predictor> SortPredictors(string username, bool ascdsc, int latest);
+ List<Predictor> SortPredictors(string userId, bool ascdsc, int latest);
void Update(string id, Predictor predictor);
}
} \ No newline at end of file
diff --git a/backend/api/api/Services/MlConnectionService.cs b/backend/api/api/Services/MlConnectionService.cs
index 22db0aea..17c0f8b8 100644
--- a/backend/api/api/Services/MlConnectionService.cs
+++ b/backend/api/api/Services/MlConnectionService.cs
@@ -67,7 +67,7 @@ namespace api.Services
public async Task<string> Predict(Predictor predictor, Experiment experiment, PredictorColumns[] inputs)
{
- string filePath = _fileService.GetFilePath(predictor.h5FileId, predictor.username);
+ string filePath = _fileService.GetFilePath(predictor.h5FileId, predictor.uploaderId);
var request = new RestRequest("predict", Method.Post);
request.AddParameter("predictor", JsonConvert.SerializeObject(predictor));
diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs
index c21844f7..d3ff9bf9 100644
--- a/backend/api/api/Services/ModelService.cs
+++ b/backend/api/api/Services/ModelService.cs
@@ -26,18 +26,18 @@ namespace api.Services
return model;
}
- public void Delete(string username, string name)
+ public void Delete(string userId, string name)
{
- _model.DeleteOne(model => (model.username == username && model.name == name));
+ _model.DeleteOne(model => (model.uploaderId == userId && model.name == name));
}
- public List<Model> GetMyModels(string username)
+ public List<Model> GetMyModels(string userId)
{
- return _model.Find(model => model.username == username).ToList();
+ return _model.Find(model => model.uploaderId == userId).ToList();
}
- public List<Model> GetLatestModels(string username)
+ public List<Model> GetLatestModels(string userId)
{
- List<Model> list = _model.Find(model => model.username == username).ToList();
+ List<Model> list = _model.Find(model => model.uploaderId == userId).ToList();
list = list.OrderByDescending(model => model.lastUpdated).ToList();
@@ -50,9 +50,9 @@ namespace api.Services
return _model.Find(model => model.isPublic == true).ToList();
}
*/
- public Model GetOneModel(string username, string name)
+ public Model GetOneModel(string userId, string name)
{
- return _model.Find(model => model.username == username && model.name == name).FirstOrDefault();
+ return _model.Find(model => model.uploaderId == userId && model.name == name).FirstOrDefault();
}
public Model GetOneModel(string id)
@@ -60,9 +60,9 @@ namespace api.Services
return _model.Find(model => model._id == id).FirstOrDefault();
}
- public void Update(string username, string name, Model model)
+ public void Update(string userId, string name, Model model)
{
- _model.ReplaceOne(model => model.username == username && model.name == name, model);
+ _model.ReplaceOne(model => model.uploaderId == userId && model.name == name, model);
}
public void Update(string id, Model model)
{
@@ -83,7 +83,7 @@ namespace api.Services
public bool CheckDb()
{
Model? model = null;
- model = _model.Find(model => model.username == "igrannonica").FirstOrDefault();
+ model = _model.Find(model => model.uploaderId == "Igrannonica").FirstOrDefault();
if (model != null)
return false;
diff --git a/backend/api/api/Services/PredictorService.cs b/backend/api/api/Services/PredictorService.cs
index 144248d4..756cc943 100644
--- a/backend/api/api/Services/PredictorService.cs
+++ b/backend/api/api/Services/PredictorService.cs
@@ -21,14 +21,14 @@ namespace api.Services
return predictor;
}
- public void Delete(string id)
+ public void Delete(string id, string userId)
{
- _predictor.DeleteOne(predictor => (predictor._id == id));
+ _predictor.DeleteOne(predictor => (predictor._id == id && predictor.uploaderId == userId));
}
- public List<Predictor> GetMyPredictors(string username)
+ public List<Predictor> GetMyPredictors(string userId)
{
- return _predictor.Find(predictor => predictor.username == username).ToList();
+ return _predictor.Find(predictor => predictor.uploaderId == userId).ToList();
}
public Predictor GetOnePredictor(string id)
@@ -36,15 +36,15 @@ namespace api.Services
return _predictor.Find(predictor => predictor._id == id).FirstOrDefault();
}
- public Predictor GetPredictor(string username, string id)
+ public Predictor GetPredictor(string userId, string id)
{
- return _predictor.Find(predictor => predictor._id == id && (predictor.username == username || predictor.isPublic == true)).FirstOrDefault();
+ return _predictor.Find(predictor => predictor._id == id && (predictor.uploaderId == userId || predictor.isPublic == true)).FirstOrDefault();
}
- public List<Predictor> SortPredictors(string username, bool ascdsc, int latest)
+ public List<Predictor> SortPredictors(string userId, bool ascdsc, int latest)
{
- List<Predictor> list = _predictor.Find(predictor => predictor.username == username).ToList();
+ List<Predictor> list = _predictor.Find(predictor => predictor.uploaderId == userId).ToList();
if (ascdsc)
list = list.OrderBy(predictor => predictor.dateCreated).ToList();
diff --git a/backend/api/api/Services/TempRemovalService.cs b/backend/api/api/Services/TempRemovalService.cs
index e7f366a3..302ca974 100644
--- a/backend/api/api/Services/TempRemovalService.cs
+++ b/backend/api/api/Services/TempRemovalService.cs
@@ -27,7 +27,7 @@ namespace api.Services
if ((DateTime.Now.ToUniversalTime() - file.date).TotalDays >= 1)
{
DeleteFile(file._id);
- List<Dataset> datasets = _dataset.Find(dataset => dataset.fileId == file._id && dataset.username=="").ToList();
+ List<Dataset> datasets = _dataset.Find(dataset => dataset.fileId == file._id && dataset.uploaderId=="").ToList();
foreach(var dataset in datasets)
{
DeleteDataset(dataset._id);
@@ -37,7 +37,7 @@ namespace api.Services
DeleteExperiment(experiment._id);
foreach(var modelId in experiment.ModelIds)
{
- var delModel=_model.Find(model=> modelId== model._id && model.username=="").FirstOrDefault();
+ var delModel=_model.Find(model=> modelId== model._id && model.uploaderId=="").FirstOrDefault();
if(delModel!= null)
DeleteModel(delModel._id);
}
@@ -48,7 +48,7 @@ namespace api.Services
}
}
//Brisanje modela ukoliko gost koristi vec postojeci dataset
- List<Model> models1= _model.Find(model =>model.username == "").ToList();
+ List<Model> models1= _model.Find(model =>model.uploaderId == "").ToList();
foreach(var model in models1)
{
if ((DateTime.Now.ToUniversalTime() - model.dateCreated.ToUniversalTime()).TotalDays >= 1)
diff --git a/backend/api/api/Services/UserService.cs b/backend/api/api/Services/UserService.cs
index 7fc4bdb1..b53f5fdc 100644
--- a/backend/api/api/Services/UserService.cs
+++ b/backend/api/api/Services/UserService.cs
@@ -51,17 +51,17 @@ namespace api.Services
using (var session = _client.StartSession())
{
if(username!=user.Username)
- if(_users.Find(u => u.Username == user.Username).FirstOrDefault()!=null)
- {
- return false;
- }
+ if(_users.Find(u => u.Username == user.Username).FirstOrDefault()!=null)
+ {
+ return false;
+ }
//Trenutan MongoDB Server ne podrzava transakcije.Omoguciti Podrsku
//session.StartTransaction();
try
{
_users.ReplaceOne(user => user.Username == username, user);
- if (username != user.Username)
+ /*if (username != user.Username)
{
var builderModel = Builders<Model>.Update;
var builderDataset = Builders<Dataset>.Update;
@@ -70,7 +70,7 @@ namespace api.Services
_datasets.UpdateMany(x => x.username == username, builderDataset.Set(x => x.username, user.Username));
_predictors.UpdateMany(x => x.username == username, builderPredictor.Set(x => x.username, user.Username));
}
-
+ */
//session.AbortTransaction();
diff --git a/backend/microservice/api/newmlservice.py b/backend/microservice/api/newmlservice.py
index a9bce3bb..9951c25f 100644
--- a/backend/microservice/api/newmlservice.py
+++ b/backend/microservice/api/newmlservice.py
@@ -156,48 +156,53 @@ def train(dataset, paramsModel,paramsExperiment,paramsDataset,callback):
#
### Enkodiranje
encoding=paramsExperiment["encoding"]
- if(encoding=='label'):
- encoder=LabelEncoder()
- for col in data.columns:
- if(data[col].dtype==np.object_):
- data[col]=encoder.fit_transform(data[col])
+ datafront=dataset.copy()
+ svekolone=datafront.columns
+ kategorijskekolone=datafront.select_dtypes(include=['object']).columns
+ for kolona in svekolone:
+ if(kolona in kategorijskekolone):
+ if(encoding=='label'):
+ encoder=LabelEncoder()
+ for col in data.columns:
+ if(data[col].dtype==np.object_):
+ data[col]=encoder.fit_transform(data[col])
- elif(encoding=='onehot'):
- category_columns=[]
- for col in data.columns:
- if(data[col].dtype==np.object_):
- category_columns.append(col)
- data=pd.get_dummies(data, columns=category_columns, prefix=category_columns)
-
- elif(encoding=='ordinal'):
- encoder = OrdinalEncoder()
- for col in data.columns:
- if(data[col].dtype==np.object_):
- data[col]=encoder.fit_transform(data[col])
-
- elif(encoding=='hashing'):
- category_columns=[]
- for col in data.columns:
- if(data[col].dtype==np.object_):
- category_columns.append(col)
- encoder=ce.HashingEncoder(cols=category_columns, n_components=len(category_columns))
- encoder.fit_transform(data)
- elif(encoding=='binary'):
- category_columns=[]
- for col in data.columns:
- if(data[col].dtype==np.object_):
- category_columns.append(col)
- encoder=ce.BinaryEncoder(cols=category_columns, return_df=True)
- encoder.fit_transform(data)
-
- elif(encoding=='baseN'):
- category_columns=[]
- for col in data.columns:
- if(data[col].dtype==np.object_):
- category_columns.append(col)
- encoder=ce.BaseNEncoder(cols=category_columns, return_df=True, base=5)
- encoder.fit_transform(data)
+ elif(encoding=='onehot'):
+ category_columns=[]
+ for col in data.columns:
+ if(data[col].dtype==np.object_):
+ category_columns.append(col)
+ data=pd.get_dummies(data, columns=category_columns, prefix=category_columns)
+
+ elif(encoding=='ordinal'):
+ encoder = OrdinalEncoder()
+ for col in data.columns:
+ if(data[col].dtype==np.object_):
+ data[col]=encoder.fit_transform(data[col])
+
+ elif(encoding=='hashing'):
+ category_columns=[]
+ for col in data.columns:
+ if(data[col].dtype==np.object_):
+ category_columns.append(col)
+ encoder=ce.HashingEncoder(cols=category_columns, n_components=len(category_columns))
+ encoder.fit_transform(data)
+ elif(encoding=='binary'):
+ category_columns=[]
+ for col in data.columns:
+ if(data[col].dtype==np.object_):
+ category_columns.append(col)
+ encoder=ce.BinaryEncoder(cols=category_columns, return_df=True)
+ encoder.fit_transform(data)
+
+ elif(encoding=='baseN'):
+ category_columns=[]
+ for col in data.columns:
+ if(data[col].dtype==np.object_):
+ category_columns.append(col)
+ encoder=ce.BaseNEncoder(cols=category_columns, return_df=True, base=5)
+ encoder.fit_transform(data)
#
# Input - output
#
diff --git a/frontend/src/app/_data/Notification.ts b/frontend/src/app/_data/Notification.ts
index c505d399..94a3be1d 100644
--- a/frontend/src/app/_data/Notification.ts
+++ b/frontend/src/app/_data/Notification.ts
@@ -1,5 +1,4 @@
export default class Notification {
- _id: string = '';
constructor(
public title: string = 'Treniranje u toku...',
public id: string = '042',
diff --git a/frontend/src/app/_elements/model-load/model-load.component.html b/frontend/src/app/_elements/model-load/model-load.component.html
index f40ea476..85caca0d 100644
--- a/frontend/src/app/_elements/model-load/model-load.component.html
+++ b/frontend/src/app/_elements/model-load/model-load.component.html
@@ -43,11 +43,7 @@
<textarea class="form-control" name="desc" rows="3" [(ngModel)]="newModel.description"></textarea>
</div>
</div>
- <div class="col-2">
- <label for="dateCreated" class="col-form-label">Datum:</label> &nbsp;&nbsp;
- <input type="text" class="form-control-plaintext" id="dateCreated" placeholder="--/--/--"
- value="{{newModel.dateCreated | date: 'dd/MM/yyyy'}}" readonly>
- </div>
+
</div>
<h2 class="mt-5 mb-4 mx-5">Parametri treniranja modela:</h2>
<div>
@@ -58,7 +54,7 @@
<label for="type" class="col-form-label">Tip problema: </label>
</div>
<div class="col-2">
- <select id=typeOptions class="form-control" name="type" [(ngModel)]="newModel.type"
+ <select id=typeOptions class="form-select" name="type" [(ngModel)]="newModel.type"
(change)="filterOptions()">
<option
*ngFor="let option of Object.keys(ProblemType); let optionName of Object.values(ProblemType)"
@@ -86,7 +82,7 @@
<label for="optimizer" class="col-form-label">Optimizacija: </label>
</div>
<div class="col-2">
- <select id=optimizerOptions class="form-control" name="optimizer" [(ngModel)]="newModel.optimizer">
+ <select id=optimizerOptions class="form-select" name="optimizer" [(ngModel)]="newModel.optimizer">
<option
*ngFor="let option of Object.keys(Optimizer); let optionName of Object.values(Optimizer)"
[value]="option">
@@ -108,10 +104,10 @@
<div class="row p-2">
<div class="col-1"></div>
<div class="col-3">
- <label for="lossFunction" class="col-form-label">Funkcija obrade gubitka: </label>
+ <label for="lossFunction" class="col-form-label">Funkcija troška: </label>
</div>
<div class="col-2">
- <select id=lossFunctionOptions class="form-control" name="lossFunction"
+ <select id=lossFunctionOptions class="form-select" name="lossFunction"
[(ngModel)]="newModel.lossFunction" aria-checked="true">
<option
*ngFor="let option of Object.keys(lossFunction); let optionName of Object.values(lossFunction)"
@@ -125,7 +121,33 @@
<label for="batchSize" class="col-form-label">Broj uzorka po iteraciji: </label>
</div>
<div class="col-1">
- <input type="number" min="1" class="form-control" name="batchSize" [(ngModel)]="newModel.batchSize">
+
+ <input type="number" min="0" step="1" max="7" class="form-control" name="batchSizePower" [(ngModel)]="batchSizePower" (click)="updateBatchSize()" >
+ {{newModel.batchSize}}
+ <!--<select id=BatchSizeOptions class="form-select" name="batchSize" [(ngModel)]="newModel.batchSize">
+ <option value="1">1</option>
+ <option value="2">2</option>
+ <option value="4">4</option>
+ <option value="8">8</option>
+ <option value="16">16</option>
+ <option value="32">32</option>
+ <option value="64">64</option>
+ <option value="128">128</option>
+ <option value="256">256</option>
+ <option value="512">512</option>
+ <option value="1024">1024</option>
+ </select>-->
+ </div>
+
+ <div class="row p-2">
+ <div class="col-1"></div>
+ <div class="col-3 m-1">
+ <label for="epochs" class="col-form-label">Broj epoha: </label>
+ </div>
+ <div class="col-1">
+ <input type="number" min="1" max="1000" class="form-control" name="epochs"
+ [(ngModel)]="newModel.epochs">
+ </div>
</div>
</div>
@@ -147,8 +169,8 @@
<div class="input-group-prepend">
<span class="input-group-text">#{{i+1}}</span>
</div>
- <select [id]="'hiddenLayerActivationFunctionOption_'+i" class="form-control"
- [(ngModel)]="newModel.hiddenLayerActivationFunctions[i]">
+ <select [id]="'hiddenLayerActivationFunctionOption_'+i" class="form-select"
+ [(ngModel)]="newModel.hiddenLayerActivationFunctions[i]" >
<option
*ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
[value]="option">
@@ -164,7 +186,7 @@
style="text-align: center;">Funkcija aktivacije<br>izlaznog sloja:</label>
</div>
<div class="col-2 mt-2">
- <select id=outputLayerActivationFunctionOptions class="form-control"
+ <select id=outputLayerActivationFunctionOptions class="form-select"
name="outputLayerActivationFunction" [(ngModel)]="newModel.outputLayerActivationFunction">
<option
*ngFor="let option of Object.keys(ActivationFunction); let optionName of Object.values(ActivationFunction)"
diff --git a/frontend/src/app/_elements/model-load/model-load.component.ts b/frontend/src/app/_elements/model-load/model-load.component.ts
index 745dc12e..aa0797bd 100644
--- a/frontend/src/app/_elements/model-load/model-load.component.ts
+++ b/frontend/src/app/_elements/model-load/model-load.component.ts
@@ -43,6 +43,11 @@ export class ModelLoadComponent implements OnInit {
ngOnInit(): void {
}
+ batchSizePower:number=1;
+ updateBatchSize()
+ {
+ this.newModel.batchSize=2**this.batchSizePower;
+ }
updateGraph() {
this.graph.update();
diff --git a/frontend/src/app/_elements/notifications/notifications.component.html b/frontend/src/app/_elements/notifications/notifications.component.html
index ef897cfc..3b2f4eaa 100644
--- a/frontend/src/app/_elements/notifications/notifications.component.html
+++ b/frontend/src/app/_elements/notifications/notifications.component.html
@@ -11,14 +11,18 @@
</button>
</h2>
- <div id="collapseNotifs" class="collapse show">
+ <div id="collapseNotifs" class="collapse show overflow-auto" style="max-height: 32rem;">
<div *ngFor="let notification of notifications" class="p-2 m-1 border rounded">
- <div class="d-flex flex-row">
- <p>{{notification.title}}</p>
- </div>
- <div *ngIf="notification.hasProgress" class="border-3 border-primary bg-dark m-1" style="height: 5px; margin-top: -10px !important;">
- <div class="bg-primary" style="height: 5px;" [style]="'width: '+(notification.progress*100)+'%;'">
+ <div class="d-flex flex-row ">
+ <div>
+ <p>{{notification.title}}</p>
+ <div *ngIf="notification.hasProgress" class="border-3 border-primary bg-dark m-1" style="height: 5px; margin-top: -10px !important; min-width: 12rem;">
+ <div class="bg-primary" style="height: 5px;" [style]="'width: '+(notification.progress*100)+'%;'">
+ </div>
+ </div>
</div>
+ <button type="button" class="btn-close ms-auto align-self-center" aria-label="Close" (click)="removeNotification(notification);"></button>
</div>
+
</div>
</div> \ No newline at end of file
diff --git a/frontend/src/app/_elements/notifications/notifications.component.ts b/frontend/src/app/_elements/notifications/notifications.component.ts
index e199f70a..9b460240 100644
--- a/frontend/src/app/_elements/notifications/notifications.component.ts
+++ b/frontend/src/app/_elements/notifications/notifications.component.ts
@@ -21,13 +21,33 @@ export class NotificationsComponent implements OnInit {
this.notifications.push(new Notification(`Obrađen izvor podataka: ${dName}`, dId, 1.0, false));
});
- this.signalRService.hubConnection.on("NotifyEpoch", (epoch: string, mName: string, mId: string, numEpochs) => {
- //todo epoch
- this.notifications.push(new Notification(`Treniranje modela: ${mName}`, mId, 0.5));
+ this.signalRService.hubConnection.on("NotifyEpoch", (mName: string, mId: string, stat: string, totalEpochs: number, currentEpoch: number) => {
+ const existingNotification = this.notifications.find(x => x.id === mId)
+ const progress = ((currentEpoch + 1) / totalEpochs);
+ console.log("Ukupno epoha", totalEpochs, "Trenutna epoha:", currentEpoch);
+ if (!existingNotification)
+ this.notifications.push(new Notification(`Treniranje modela: ${mName}`, mId, progress, true));
+ else {
+ existingNotification.progress = progress;
+ }
+ });
+
+ this.signalRService.hubConnection.on("NotifyModel", (mName: string, mId: string, stat: string, totalEpochs: number, currentEpoch: number) => {
+ const existingNotification = this.notifications.find(x => x.id === mId)
+ const progress = ((currentEpoch + 1) / totalEpochs);
+ if (!existingNotification)
+ this.notifications.push(new Notification(`Treniranje modela: ${mName}`, mId, progress, true));
+ else {
+ existingNotification.progress = progress;
+ }
});
} else {
console.warn("Notifications: No connection!");
}
}
+ removeNotification(notification: Notification) {
+ this.notifications.splice(this.notifications.indexOf(notification), 1);
+ }
+
}
diff --git a/frontend/src/app/app-routing.module.ts b/frontend/src/app/app-routing.module.ts
index e22f7a88..238668d9 100644
--- a/frontend/src/app/app-routing.module.ts
+++ b/frontend/src/app/app-routing.module.ts
@@ -20,6 +20,7 @@ const routes: Routes = [
/*{ path: 'add-model', component: AddModelComponent, data: { title: 'Dodaj model' } },*/
{ path: 'experiment', component: ExperimentComponent, data: { title: 'Dodaj eksperiment' } },
{ path: 'training', component: TrainingComponent, data: { title: 'Treniraj model' } },
+ { path: 'training/:id', component: TrainingComponent, data: { title: 'Treniraj model' } },
{ path: 'my-datasets', component: MyDatasetsComponent, canActivate: [AuthGuardService], data: { title: 'Moji izvori podataka' } },
{ path: 'my-models', component: MyModelsComponent, canActivate: [AuthGuardService], data: { title: 'Moji modeli' } },
{ path: 'my-predictors', component: MyPredictorsComponent, canActivate: [AuthGuardService], data: { title: 'Moji trenirani modeli' } },
@@ -28,6 +29,7 @@ const routes: Routes = [
{ path: 'browse-datasets', component: FilterDatasetsComponent, data: { title: 'Javni izvori podataka' } },
{ path: 'browse-predictors', component: BrowsePredictorsComponent, data: { title: 'Javni trenirani modeli' } },
{ path: 'predict/:id', component: PredictComponent, data: { title: 'Predvidi vrednosti' } },
+
];
@NgModule({