Skip to content

Commit

Permalink
Feature: create graphs endpoints to list, create and delete (#115)
Browse files Browse the repository at this point in the history
* fix: docker-compose app volume

* fix ncbo_ontology_recommender version

* add admin graphs controller to list triple store graphs and delete them

* update gemfile

* extract graph count path in a constant

* add graphs admin action unit tests
  • Loading branch information
syphax-bouazzouni authored Jan 23, 2025
1 parent 909a8aa commit 07290db
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.6
2.7.5
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ gem 'redcarpet'

# NCBO gems (can be from a local dev path or from rubygems/git)
gem 'ncbo_annotator', git: 'https://github.com/ontoportal-lirmm/ncbo_annotator.git', branch: 'development'
gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branch: 'master'
gem 'ncbo_ontology_recommender', git: 'https://github.com/ncbo/ncbo_ontology_recommender.git', branch: 'master'
gem 'ncbo_cron', git: 'https://github.com/ontoportal-lirmm/ncbo_cron.git', branch: 'development'
gem 'ncbo_ontology_recommender', git: 'https://github.com/ontoportal-lirmm/ncbo_ontology_recommender.git', branch: 'development'
gem 'goo', github: 'ontoportal-lirmm/goo', branch: 'development'
gem 'sparql-client', github: 'ontoportal-lirmm/sparql-client', branch: 'development'
gem 'ontologies_linked_data', git: 'https://github.com/ontoportal-lirmm/ontologies_linked_data.git', branch: 'development'
Expand Down
112 changes: 57 additions & 55 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
GIT
remote: https://github.com/ncbo/ncbo_ontology_recommender.git
revision: 9dbd4f179e42c52095129d353a5ac584e9bd47f3
branch: master
specs:
ncbo_ontology_recommender (0.0.1)
goo
ncbo_annotator
ontologies_linked_data
redis

GIT
remote: https://github.com/ontoportal-lirmm/goo.git
revision: f8ac7b00e8d8b46d1eea04de014175525c1cdd83
revision: 27300f28ca6c656c7e78af65013d88b792a6312f
branch: development
specs:
goo (0.0.2)
Expand Down Expand Up @@ -40,8 +29,8 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_cron.git
revision: bed0ff08408ad1241db3513992ad025a253eeef0
branch: master
revision: dd736917974f13ac7558e0d2a61a84030d82acaa
branch: development
specs:
ncbo_cron (0.0.1)
dante
Expand All @@ -55,9 +44,20 @@ GIT
redis
rufus-scheduler (~> 2.0.24)

GIT
remote: https://github.com/ontoportal-lirmm/ncbo_ontology_recommender.git
revision: a0e36c89e6e2f8502cac288df2992625649dad7a
branch: development
specs:
ncbo_ontology_recommender (0.0.1)
goo
ncbo_annotator
ontologies_linked_data
redis

GIT
remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git
revision: 312ef426eeaa461e88fa23124ea5fd531f4276ba
revision: 6cb18910e322645e3cc3490951d10f19468da52f
branch: development
specs:
ontologies_linked_data (0.0.1)
Expand All @@ -77,7 +77,7 @@ GIT

GIT
remote: https://github.com/ontoportal-lirmm/sparql-client.git
revision: 59251e59346c9a69a67c88552ba55a1244eec602
revision: 4364d34e9e4c411f1dd0ea706bf052465bf0b467
branch: development
specs:
sparql-client (3.2.2)
Expand Down Expand Up @@ -117,9 +117,9 @@ GEM
base64 (0.2.0)
bcrypt (3.1.20)
bcrypt_pbkdf (1.1.1)
bigdecimal (3.1.8)
bigdecimal (3.1.9)
builder (3.3.0)
capistrano (3.19.1)
capistrano (3.19.2)
airbrussh (>= 1.0.0)
i18n
rake (>= 10.0.0)
Expand All @@ -132,13 +132,13 @@ GEM
capistrano (~> 3.1)
sshkit (~> 1.3)
coderay (1.1.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
crack (0.4.5)
rexml
cube-ruby (0.0.3)
dante (0.2.0)
date (3.3.4)
date (3.4.1)
declarative (0.0.20)
docile (1.4.1)
domain_name (0.6.20240107)
Expand All @@ -164,12 +164,12 @@ GEM
google-analytics-data (0.6.1)
google-analytics-data-v1beta (>= 0.11, < 2.a)
google-cloud-core (~> 1.6)
google-analytics-data-v1beta (0.13.1)
google-analytics-data-v1beta (0.14.0)
gapic-common (>= 0.21.1, < 2.a)
google-cloud-errors (~> 1.0)
google-apis-analytics_v3 (0.16.0)
google-apis-core (>= 0.15.0, < 2.a)
google-apis-core (0.15.1)
google-apis-core (0.16.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (~> 1.9)
httpclient (>= 2.8.3, < 3.a)
Expand All @@ -188,7 +188,7 @@ GEM
google-protobuf (>= 3.18, < 5.a)
googleapis-common-protos-types (~> 1.7)
grpc (~> 1.41)
googleapis-common-protos-types (1.16.0)
googleapis-common-protos-types (1.18.0)
google-protobuf (>= 3.18, < 5.a)
googleauth (1.11.2)
faraday (>= 1.0, < 3.a)
Expand All @@ -203,27 +203,27 @@ GEM
haml (5.2.2)
temple (>= 0.8.0)
tilt
hashdiff (1.1.1)
hashdiff (1.1.2)
htmlentities (4.3.4)
http-accept (1.7.0)
http-cookie (1.0.7)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.6)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.7.5)
json (2.9.1)
json-ld (3.0.2)
multi_json (~> 1.12)
rdf (>= 2.2.8, < 4.0)
json-schema (2.8.1)
addressable (>= 2.4)
jwt (2.9.3)
jwt (2.10.1)
base64
kgio (2.11.4)
language_server-protocol (3.17.0.3)
libxml-ruby (5.0.3)
link_header (0.0.8)
logger (1.6.1)
logger (1.6.5)
macaddr (1.7.2)
systemu (~> 2.6.5)
mail (2.8.1)
Expand All @@ -235,49 +235,49 @@ GEM
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.1001)
mime-types-data (3.2025.0107)
mini_mime (1.1.5)
minitest (5.25.1)
minitest (5.25.4)
minitest-hooks (1.5.2)
minitest (> 5.3)
minitest-stub_any_instance (1.0.3)
mlanett-redis-lock (0.2.7)
redis
multi_json (1.15.0)
mutex_m (0.2.0)
net-http-persistent (4.0.4)
mutex_m (0.3.0)
net-http-persistent (4.0.5)
connection_pool (~> 2.2)
net-imap (0.4.17)
net-imap (0.4.18)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.2)
timeout
net-scp (4.0.0)
net-scp (4.1.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-sftp (4.0.0)
net-ssh (>= 5.0.0, < 8.0.0)
net-smtp (0.5.0)
net-protocol
net-ssh (7.3.0)
netrc (0.11.0)
newrelic_rpm (9.14.0)
oj (3.16.6)
newrelic_rpm (9.16.1)
oj (3.16.9)
bigdecimal (>= 3.0)
ostruct (>= 0.2)
omni_logger (0.1.4)
logger
os (1.1.4)
ostruct (0.6.0)
ostruct (0.6.1)
parallel (1.26.3)
parseconfig (1.1.2)
parser (3.3.5.0)
parser (3.3.7.0)
ast (~> 2.4.1)
racc
pony (1.13.1)
mail (>= 2.0)
pry (0.14.2)
pry (0.15.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.1.1)
Expand All @@ -295,7 +295,7 @@ GEM
rack (>= 1.2.0)
rack-protection (1.5.5)
rack
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rack-timeout (0.7.0)
rainbow (3.1.1)
Expand All @@ -319,14 +319,14 @@ GEM
redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.22.2)
redis-client (0.23.2)
connection_pool
redis-rack-cache (2.2.1)
rack-cache (>= 1.10, < 2)
redis-store (>= 1.6, < 2)
redis-store (1.11.0)
redis (>= 4, < 6)
regexp_parser (2.9.2)
regexp_parser (2.10.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand All @@ -339,26 +339,26 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
retriable (3.1.2)
rexml (3.3.9)
rexml (3.4.0)
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
rubocop (1.67.0)
rubocop (1.71.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.36.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.33.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby-xxHash (0.4.0.2)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
rubyzip (2.4.1)
rufus-scheduler (2.0.24)
tzinfo (>= 0.3.22)
signet (0.19.0)
Expand Down Expand Up @@ -397,13 +397,15 @@ GEM
systemu (2.6.5)
temple (0.10.3)
thread_safe (0.3.6)
tilt (2.4.0)
timeout (0.4.1)
tilt (2.6.0)
timeout (0.4.3)
trailblazer-option (0.1.2)
tzinfo (1.2.11)
thread_safe (~> 0.1)
uber (0.1.0)
unicode-display_width (2.6.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
unicorn (6.1.0)
kgio (~> 2.6)
raindrops (~> 0.7)
Expand All @@ -416,7 +418,7 @@ GEM
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webrick (1.8.2)
webrick (1.9.1)

PLATFORMS
x86_64-linux
Expand Down
1 change: 1 addition & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,6 @@
NcboCron.config do |config|
config.redis_host = REDIS_PERSISTENT_HOST.to_s
config.redis_port = REDIS_PORT.to_i
config.graphs_counts_report_path = './test/ontologies_report.json'
# config.ontology_report_path = REPORT_PATH
end
34 changes: 34 additions & 0 deletions controllers/admin_graphs_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'ncbo_cron/graphs_counts'
class AdminGraphsController < ApplicationController

namespace '/admin' do
GRAPH_COUNT_REPORT_PATH = NcboCron.settings.graphs_counts_report_path
before do
if LinkedData.settings.enable_security && (!env['REMOTE_USER'] || !env['REMOTE_USER'].admin?)
error 403, 'Access denied'
end
end

get '/graphs' do
output = NcboCron::GraphsCounts.new(nil, GRAPH_COUNT_REPORT_PATH).read_graph_counts
reply output
end

post '/graphs' do
generate_graphs_counts
reply({ message: 'Graph counts generated', status: 200 })
end

delete '/graphs' do
url = params['url']
error 400, 'You must provide a valid URL for the graph to delete' if url.blank?
Goo.sparql_data_client.delete_graph(url)
generate_graphs_counts
reply({ message: "Graph #{url} deleted", status: 200 })
end

def generate_graphs_counts
NcboCron::GraphsCounts.new(nil, GRAPH_COUNT_REPORT_PATH).run
end
end
end
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ services:
- "9393:9393"
volumes:
# bundle volume for hosting gems installed by bundle; it speeds up gem install in local development
- .:/srv/ontoportal/ontologies_api
- app_api:/srv/ontoportal/ontologies_api
- repository:/srv/ontoportal/data/repository

ncbo_cron:
Expand Down Expand Up @@ -199,4 +199,3 @@ volumes:
mgrep:
logs:
history:

2 changes: 2 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
ruby = "2.7.8"
Loading

0 comments on commit 07290db

Please sign in to comment.