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

Feature/ai builder connector #408

Merged
merged 26 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d9b2fcb
Merged with develop
AdrianAlcolea Oct 30, 2024
23bff69
Structure with empty token
AdrianAlcolea Nov 12, 2024
7120152
Merging with develop
AdrianAlcolea Nov 12, 2024
9315029
Wotking with hidden token
AdrianAlcolea Nov 12, 2024
44b2a25
Infinite loop on empty lists solved
AdrianAlcolea Nov 12, 2024
a2a4a2c
Merged with develop
AdrianAlcolea Nov 25, 2024
fbb2e8b
Happy path test of aibuilder connector
AdrianAlcolea Nov 25, 2024
a56bceb
First working test for aibuilder connector
AdrianAlcolea Dec 3, 2024
cef4a1f
Merged with develop
AdrianAlcolea Dec 3, 2024
4e673f4
Catalog list tests done
AdrianAlcolea Dec 4, 2024
b743d3c
All AIBuilder Connector test passed
AdrianAlcolea Dec 4, 2024
1e6d374
Merged with develop
AdrianAlcolea Dec 4, 2024
c45c4f7
TODO removed. Continuation after catalog error is not needed.
AdrianAlcolea Dec 4, 2024
6f9e5c9
Changed the venv name and removed the venv_aiod directory
AdrianAlcolea Dec 10, 2024
f6fe330
Added aibuilder to the example for usin connectors on the README
AdrianAlcolea Dec 10, 2024
4d7eb43
Documentation texts added to the aibuilder connector class and methods
AdrianAlcolea Dec 10, 2024
393a4eb
Modified same_as field for security reasons
AdrianAlcolea Dec 10, 2024
06de5cd
Comment about same_as field aded to the README file
AdrianAlcolea Dec 10, 2024
9648c09
Comment about same_as field aded to the README file
AdrianAlcolea Dec 10, 2024
9d4749e
Comment about same_as field aded to the README file
AdrianAlcolea Dec 10, 2024
4c6a2e7
Modifications for the Pull Request
AdrianAlcolea Dec 18, 2024
cf691b9
Removed extra set_token method
AdrianAlcolea Dec 18, 2024
a8a17c9
Handle successfull requests without json response. Also specific mess…
AdrianAlcolea Dec 19, 2024
16b63d3
Added unitary test for Unauthorized token error.
AdrianAlcolea Dec 19, 2024
f92b15e
Removed .env file from docker_compose
AdrianAlcolea Dec 19, 2024
8fc4c0b
Merged with develop
AdrianAlcolea Dec 19, 2024
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
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ AIOD_KEYCLOAK_PORT=8080

EGICHECKINALIAS=

#AIBUILDER
AIBUILDER_API_TOKEN=""

#ELASTICSEARCH
ES_USER=elastic
ES_PASSWORD=changeme
Expand Down
14 changes: 14 additions & 0 deletions connectors/aibuilder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM aiod_metadata_catalogue

USER root
RUN apt-get update
RUN apt -y install cron

COPY cron /etc/cron.d/aiod
COPY mlmodels.sh /opt/connectors/script/mlmodels.sh
COPY entry.sh /opt/connectors/script/entry.sh
PGijsbers marked this conversation as resolved.
Show resolved Hide resolved

RUN chmod +x /etc/cron.d/aiod /opt/connectors/script/mlmodels.sh
RUN crontab /etc/cron.d/aiod

WORKDIR /app
1 change: 1 addition & 0 deletions connectors/aibuilder/cron
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
40 * * * * bash /opt/connectors/script/mlmodels.sh >> /opt/connectors/data/aibuilder/mlmodel/cron.log 2>&1
7 changes: 7 additions & 0 deletions connectors/aibuilder/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# If this directory does not exist, the cron job cannot log (and cannot run)
mkdir -p /opt/connectors/data/aibuilder/mlmodel

# Run cron on the foreground with log level WARN
/usr/sbin/cron -f -l 4
20 changes: 20 additions & 0 deletions connectors/aibuilder/mlmodels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

WORK_DIR=/opt/connectors/data/aibuilder/mlmodel
CONNECTOR=connectors.aibuilder.aibuilder_mlmodel_connector.AIBuilderMLModelConnector

another_instance()
{
echo $(date -u) "This script is already running in a different thread."
exit 1
}
exec 9< "$0"
flock -n -x 9 || another_instance

echo $(date -u) "Starting synchronization..."
PYTHONPATH=/app /usr/local/bin/python3 /app/connectors/synchronization.py \
-c $CONNECTOR \
-w $WORK_DIR \
--from-date "2020-06-21" \
--save-every 100 >> ${WORK_DIR}/connector.log 2>&1
echo $(date -u) "Synchronization Done."
19 changes: 19 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ services:
app:
condition: service_healthy

aibuilder-connector:
profiles: ["aibuilder"]
build:
context: connectors/aibuilder
dockerfile: Dockerfile
image: aiod_aibuilder_connector
container_name: aibuilder-connector
environment:
- KEYCLOAK_CLIENT_SECRET=$KEYCLOAK_CLIENT_SECRET
- AIBUILDER_API_TOKEN=$AIBUILDER_API_TOKEN
volumes:
- ./src:/app
- ${DATA_PATH}/connectors:/opt/connectors/data
command: >
/bin/bash -c "/opt/connectors/script/entry.sh"
depends_on:
app:
condition: service_healthy

sqlserver:
image: mysql:8.3.0
container_name: sqlserver
Expand Down
9 changes: 7 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,18 @@ It follows the same structure as the default file, but you only need to specify
You can specify different connectors using

```bash
docker compose --profile examples --profile huggingface-datasets --profile openml --profile zenodo-datasets up -d
docker compose --profile examples --profile huggingface-datasets --profile openml --profile zenodo-datasets down
docker compose --profile aibuilder --profile examples --profile huggingface-datasets --profile openml --profile zenodo-datasets up -d
docker compose --profile aibuilder --profile examples --profile huggingface-datasets --profile openml --profile zenodo-datasets down
```

Make sure you use the same profile for `up` and `down`, or use `./scripts/down.sh` (see below),
otherwise some containers might keep running.

##### Configuring AIBuilder connector
To access the AIBuilder API you need to provide a valid API token through the `AIBUILDER_API_TOKEN` variable. \
Use the `override.env` file for that as explained above. \
Please note that for using the url of the `same_as` field of the AIBuilder models, you will need to substitute `AIBUILDER_API_TOKEN` on the url for your actual API token value.

### Shorthands
We provide two auxiliary scripts for launching docker containers and bringing them down.
The first, `./scripts/up.sh` invokes `docker compose up -d` and takes any number of profiles to launch as parameters.
Expand Down
Empty file.
9 changes: 9 additions & 0 deletions src/connectors/aibuilder/aibuilder_mappings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mlmodel_mapping = {
"platform_resource_identifier": "fullId",
"name": "name",
"date_published": "created",
"contact": "authors",
"creator": "publisher",
"description": "description",
"keyword": "tags",
}
Loading
Loading