Skip to content

Commit

Permalink
modified: CHANGELOG.md
Browse files Browse the repository at this point in the history
	modified:   Project.toml
	modified:   src/AutomationLabsDepot.jl
	modified:   src/database_management/database_systems_management.jl
  • Loading branch information
Pierre BLAUD committed Apr 16, 2023
1 parent 5792aed commit d396b54
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# AutomationLabsDepot Changelog

## v0.1.12

* Add stats_system_local_folder_db methods for the systems.
* Add stats_model_local_folder_db methods export for the models.

## v0.1.11

* Add exportation management methods for the depot.
Expand Down
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name = "AutomationLabsDepot"
uuid = "cc8afec4-1da4-4339-ab39-14f2715a249b"
authors = ["Pierre Blaud <pierre.blaud@ikmail.com> and contributors"]
version = "0.1.11"
version = "0.1.12"

[deps]
AutomationLabsSystems = "6d3dfdf0-e107-48c6-a6ff-eced1a5a9334"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand All @@ -18,16 +19,17 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

[compat]
AutomationLabsSystems = "0.1"
CSV = "0.10"
CUDA = "4"
DataFrames = "1"
DuckDB = "0.7"
FilePathsBase = "0.9"
JLD2 = "0.4"
MLJ = "0.19"
Parquet2 = "0.2"
PlotlyJS = "0.18"
StatsBase = "0.33"
JLD2 = "0.4"
julia = "1"

[extras]
Expand Down
5 changes: 4 additions & 1 deletion src/AutomationLabsDepot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
module AutomationLabsDepot

#package needed
import CSV #needed?
import CSV
import DataFrames
import Dates
import DuckDB
Expand All @@ -20,6 +20,7 @@ import Random
import PlotlyJS
import CUDA #needed?
import StatsBase
import AutomationLabsSystems

# iodata
export iodata_local_folder_db
Expand All @@ -41,6 +42,7 @@ export remove_iodata_local_folder_db
export list_model_local_folder_db
export remove_model_local_folder_db
export add_model_local_folder_db
export stats_model_local_folder_db

# controller local disk db
export list_controller_local_folder_db
Expand All @@ -59,6 +61,7 @@ export list_system_local_folder_db
export remove_system_local_folder_db
export add_system_local_folder_db
export load_system_local_folder_db
export stats_system_local_folder_db

# exportations local disk db
export list_exportation_local_folder_db
Expand Down
64 changes: 61 additions & 3 deletions src/database_management/database_systems_management.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function add_system_local_folder_db(system, project_name, system_name)
return nothing
end

# load controller from local folder
# load system from local folder
function load_system_local_folder_db(project_name, system_name)

# Connect to the database
Expand All @@ -131,15 +131,15 @@ function load_system_local_folder_db(project_name, system_name)
path_db = DEPOT_PATH[begin] * "/automationlabs/database/automationlabs.duckdb"
con = DBInterface.connect(DuckDB.DB, path_db)

# Evaluate if the controller is in the database
# Evaluate if the system is in the database
c_list = DuckDB.toDataFrame(
DBInterface.execute(
con,
"SELECT id, path, name, file_extension, added, size FROM $project_name.systems WHERE name = '$system_name';",
),
)
if size(c_list, 1) == 0
@warn "The controller is not present in the database"
@warn "The system is not present in the database"
return false
end

Expand All @@ -154,3 +154,61 @@ function load_system_local_folder_db(project_name, system_name)

return system_p
end

# Get the statistics of a system
function stats_system_local_folder_db(project_name::String, system_name::String)

# Connect to the database
path_db = DEPOT_PATH[begin] * "/automationlabs/database/automationlabs.duckdb"
con = DBInterface.connect(DuckDB.DB, path_db)

# Evaluate if the project is in the database
project_list = DuckDB.toDataFrame(
DBInterface.execute(con, "SELECT * FROM information_schema.schemata;"),
)
if findall(x -> x == project_name, project_list[!, :schema_name]) == []
@warn "unrecognized project name"
return false
end

# Evaluate if the system is in the database
c_list = DuckDB.toDataFrame(
DBInterface.execute(
con,
"SELECT id, path, name, file_extension, added, size FROM $project_name.systems WHERE name = '$system_name';",
),
)
if size(c_list, 1) == 0
@warn "The system is not present in the database"
return false
end

# Load path data into local depot folder
path_model =
DEPOT_PATH[begin] * "/automationlabs" * "/" * "systems" * "/" * system_name * ".jld2"

# Evaluate if the files are in the depot folder
if isfile(path_model) == false
@warn "unrecognized system in depot folder"
return false
end

# Load the model from the database
system_loaded = load_system_local_folder_db(project_name, system_name)

# Get the mathematical systme type
sys_type = AutomationLabsSystems.proceed_system_evaluation(system_loaded)

# Get states and inputs constraints
x_cons, u_cons = AutomationLabsSystems.proceed_system_constraints_evaluation(system_loaded)

# Close and disconnect the DuckDB database
DBInterface.close!(con)

return [
sys_type,
x_cons,
u_cons,
]
end

0 comments on commit d396b54

Please sign in to comment.