Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix anonymous access & prepare 4.4 #355

Merged
merged 13 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This changelog was started for release 4.2.0.
- Fixed an issue with forms (missing field and entity name for label & uri fields) (Issue #255)
- Fixed an issue with the data endpoint for FALDO entities (Issue #279)
- Fixed an issue where integration would fail when setting a category type on a empty column (#334)
- Fixed an issue with saved queries for non-logged users

### Added

Expand All @@ -28,12 +29,15 @@ This changelog was started for release 4.2.0.
- Add better error management for RDF files
- Added 'single tenant' mode: Send queries to all graphs to speed up
- Added ontologies management
- Added prefixes management
- Added 'external graph' management for federated request: federated requests will only target this remote graph
- Added support for multithread in web server, with the *WORKERS* env variable when calling make

### Changed

- Changed "Query builder" to "Form editor" in form editing interface
- Changed abstraction building method for relations. (Please refer to #248 and #268)
- Changed abstraction building method for attributes. (Please refer to #321 and #324)
- Changed abstraction building method for relations. (Please refer to #248 and #268). Correct 'phantom' relations
- Changed abstraction building method for attributes. (Please refer to #321 and #324). Correct 'attributes' relations
- Changed abstraction building method for 'strand': only add the required strand type, and not all three types (#277)
- Updated documentation
- Changed the sparql endpoint: now use the authenticated SPARQL endpoint instead of public endpoint. Write permissions are not required anymore
Expand Down
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ FLASKOPTS=
PYTESTOPTS=
TESTFILE?=tests
NTASKS?=1
WORKERS?=1

HOST?=0.0.0.0
PORT?=5000
Expand Down Expand Up @@ -52,20 +53,20 @@ help:
@echo ' make clean Uninstall everything'
@echo ' make install [MODE=dev] Install Python and Js dependencies (+ dev dependencies if MODE=dev)'
@echo ' make build [MODE=dev] Build javascript (and watch for update if MODE=DEV)'
@echo ' make serve [MODE=dev] [HOST=0.0.0.0] [PORT=5000] [NTASKS=1] Serve AskOmics at $(HOST):$(PORT)'
@echo ' make serve [MODE=dev] [HOST=0.0.0.0] [PORT=5000] [NTASKS=1] [WORKERS=1] Serve AskOmics at $(HOST):$(PORT)'
@echo ' make test Lint and test javascript and python code'
@echo ' make serve-doc [DOCPORT=8000] Serve documentation at localhost:$(DOCPORT)'
@echo ' make update-base-url Update all graphs from an old base_url to a new base_url'
@echo ' make clear-cache Clear abstraction cache'
@echo ''
@echo 'Examples:'
@echo ' make clean install build serve NTASKS=10 Clean install and serve AskOmics in production mode, 10 celery tasks in parallel'
@echo ' make clean install serve MODE=dev NTASKS=10 Clean install and serve AskOmics in development mode, 10 celery tasks in parallel'
@echo ' make clean install build serve NTASKS=10 WORKERS=2 Clean install and serve AskOmics in production mode, 10 celery tasks in parallel, 2 workers on the web server'
@echo ' make clean install serve MODE=dev NTASKS=10 WORKERS=2 Clean install and serve AskOmics in development mode, 10 celery tasks in parallel, 2 workers on the web server'
@echo ''
@echo ' make clean install Clean install AskOmics'
@echo ' make clean install MODE=dev Clean install AskOmics in development mode'
@echo ' make serve NTASKS=10 Serve AskOmics, 10 celery tasks in parallel'
@echo ' make serve MODE=dev NTASKS=10 Serve AskOmics in development mode, 10 celery tasks in parallel'
@echo ' make serve NTASKS=10 WORKERS=2 Serve AskOmics, 10 celery tasks in parallel, 2 workers on the web server'
@echo ' make serve MODE=dev NTASKS=10 WORKERS=2 Serve AskOmics in development mode, 10 celery tasks in parallel, 2 workers on the web server'
@echo ''
@echo ' make pytest MODE=dev TESTFILE=tests/test_api.py Test tests/test_api file only'

Expand Down Expand Up @@ -106,7 +107,7 @@ serve-askomics: check-venv build-config create-user
ifeq ($(MODE), dev)
FLASK_ENV=development FLASK_APP=app flask run --host=$(HOST) --port $(PORT)
else
FLASK_ENV=production FLASK_APP=app gunicorn -b $(HOST):$(PORT) app
FLASK_ENV=production FLASK_APP=app gunicorn -w $(WORKERS) -b $(HOST):$(PORT) app
endif

serve-celery: check-venv build-config create-user
Expand Down
4 changes: 3 additions & 1 deletion askomics/api/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@


def can_access(user):
if not user:
return False
login_allowed = current_app.iniconfig.getboolean('askomics', 'enable_sparql_console', fallback=False)
return login_allowed or user['admin']

Expand Down Expand Up @@ -166,7 +168,7 @@ def get_graph_and_sparql_query():
# Get all graphs and endpoint, and mark as selected the used one
query = SparqlQuery(current_app, session, get_graphs=True)
graphs, endpoints = query.get_graphs_and_endpoints(selected_graphs=graphs, selected_endpoints=endpoints)
console_enabled = can_access(session['user'])
console_enabled = can_access(session.get('user'))

except Exception as e:
traceback.print_exc(file=sys.stdout)
Expand Down
18 changes: 11 additions & 7 deletions askomics/libaskomics/OntologyManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,19 @@ def autocomplete(self, ontology_uri, ontology_type, query_term, onto_short_name,
"fieldList": "label"
}

r = requests.get(base_url, params=arguments)

data = []

if not r.status_code == 200:
return data
try:
r = requests.get(base_url, params=arguments, timeout=10)

if not r.status_code == 200:
return data

res = r.json()
if res['response']['docs']:
data = [term['label'] for term in res['response']['docs']]

res = r.json()
if res['response']['docs']:
data = [term['label'] for term in res['response']['docs']]
except requests.exceptions.Timeout:
pass

return data
2 changes: 1 addition & 1 deletion askomics/react/src/routes/query/ontolinkview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class OntoLinkView extends Component {
<option selected={this.props.link.uri == '^http://www.w3.org/2000/01/rdf-schema#subClassOf*' ? true : false} value="^http://www.w3.org/2000/01/rdf-schema#subClassOf*">ancestors of</option>
</CustomInput>
</td>
<td> a term</td>
<td>&nbsp;a term</td>
</tr>
</table>
<br />
Expand Down
12 changes: 6 additions & 6 deletions askomics/react/src/routes/query/query.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export default class Query extends Component {
target: targetId,
selected: false,
suggested: true,
directed: isOnto ? false : true,
directed: true,
})
incrementSpecialNodeGroupId ? specialNodeGroupId += 1 : specialNodeGroupId = specialNodeGroupId
}
Expand Down Expand Up @@ -703,7 +703,7 @@ export default class Query extends Component {
target: node1.id,
selected: false,
suggested: false,
directed: link.direct,
directed: link.directed,
}
}
})
Expand Down Expand Up @@ -1345,10 +1345,10 @@ export default class Query extends Component {

getOntoLabel (uri) {
let labels = {}
labels["http://www.w3.org/2000/01/rdf-schema#subClassOf"] = "Children of"
labels["http://www.w3.org/2000/01/rdf-schema#subClassOf*"] = "Descendants of"
labels["^http://www.w3.org/2000/01/rdf-schema#subClassOf"] = "Parents of"
labels["^http://www.w3.org/2000/01/rdf-schema#subClassOf*"] = "Ancestors of"
labels["http://www.w3.org/2000/01/rdf-schema#subClassOf"] = "is children of"
labels["http://www.w3.org/2000/01/rdf-schema#subClassOf*"] = "is descendant of"
labels["^http://www.w3.org/2000/01/rdf-schema#subClassOf"] = "is parents of"
labels["^http://www.w3.org/2000/01/rdf-schema#subClassOf*"] = "is ancestor of"
return labels[uri]
}

Expand Down
2 changes: 1 addition & 1 deletion askomics/static/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h4>What is AskOmics?</h4>
Visit <a target="_newtab" rel="noopener noreferrer" href="https://askomics.org">askomics.org</a> to learn how to use and deploy AskOmics.
</p>

<h4>Usefull links</h4>
<h4>Useful links</h4>
<p>
<div>
<a target="_newtab" rel="noopener noreferrer" href="https://flaskomics.readthedocs.io">Docs</a>
Expand Down
3 changes: 0 additions & 3 deletions config/askomics.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,6 @@ preview_limit = 25
# All queries are launched on all graphes (speedup queries)
single_tenant=False

# Max results returned for autocompletion
autocomplete_max_results = 10

[federation]
# Query engine can be corese or fedx
#query_engine = corese
Expand Down
Loading