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

Changes resources #229

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Deploy NFDI Search Engine on sems-kg-1'
on:
workflow_dispatch:
push:
branches:
branches:
- main

jobs:
Expand All @@ -18,7 +18,11 @@ jobs:
- name: 'Delete old Docker image'
run: docker image rm nfdi-search-engine-search-engine
- name: 'Copy logging.conf'
<<<<<<< HEAD
run: cp logging.conf.example logging.conf
=======
run: cp logging.conf.example logging.conf
>>>>>>> origin/develop
- name: 'Create .env'
run: |
echo "OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}" >> ./.env
Expand Down
18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "windows-gcc-x86",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "E:/make/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x86",
"compilerArgs": [
""
]
}
],
"version": 4
}
62 changes: 62 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false,
"files.associations": {
"iostream": "cpp"
}
}
66 changes: 66 additions & 0 deletions a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import urllib.parse
import requests
import logging
import utils
import json
from sources import data_retriever
from objects import CreativeWork, Author

base_url = "https://zenodo.org/api/records?size=25&q="
doi = "r3730f562f9e::324df2bd7d05a0942f31f0fe34e2eefa"

# search_result = data_retriever.retrieve_single_object(source=source,
# base_url=
# doi=doi)

encoded_doi = urllib.parse.quote_plus(string=doi, safe='()?&=,')
url = base_url + encoded_doi
print(url)
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': utils.config["request_header_user_agent"]
}

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

try:
response = requests.get(url, headers=headers, timeout=int(utils.config["request_timeout"]))
logger.debug(f'Response status code: {response.status_code}')

if response.status_code == 200:
search_results = response.json()
search_results = utils.clean_json(search_results)
# print(search_result)
search_result = search_results.get("hits", {}).get("hits", [])
search_result = search_result[0]
metadata = search_result.get("metadata", {})
resource = CreativeWork()
resource.name = metadata.get("title", "")
resource.url = metadata.get('links', {}).get('self', '')
resource.identifier = metadata.get("doi", "")
resource.datePublished = metadata.get("publication_date", "")
resource.inLanguage.append(metadata.get("language", ""))
resource.license = metadata.get("license", "")

resource.description = utils.remove_html_tags(metadata.get("description", ""))
resource.abstract = resource.description

authors = metadata.get("creators", [])
for author in authors:
_author = Author()
_author.type = 'Person'
_author.name = author.get("name", "")
_author.identifier = author.get("orcid", "")
_author.affiliation = author.get("affiliation", "")
resource.author.append(_author)
# print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
print(json.dumps(search_result, indent=4))
# print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
# print( resource.name)
else:
logger.error(f'Failed to retrieve data: {response.status_code}')

except requests.exceptions.RequestException as e:
logger.error(f'An error occurred: {e}')
Loading