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

Create Dockerfile for LibraryMetricScripts and Pull librarycomparisonswebsite images from Docker Hub #43

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

XiaoleZ
Copy link
Collaborator

@XiaoleZ XiaoleZ commented Jan 15, 2021

What it does?

Create Dockerfile for LibraryMetricScripts and Pull librarycomparisonswebsite images from Docker Hub

Why it is import?

It makes the database setup more easier and it allows the user to run librarycomparisonswebsite locally

How to test it?

Follow the updated Readme.md file.

Docker Local Development Setup

This is a simple way to get a local librarycomparison web development server set up.

You'll need to have Docker and Docker Compose installed.

  • You first need to set up some of the configuration parameters in the file Config.json:

  • You can update the MAXSIZE to 100 in Config.json for testing purpose.

Creating the image

1. Builds/Rebuilds the image (not start the containers) in the docker-compose.yml file:

docker-compose build --no-cache

2. Starts the containers

Starts the containers && Start the server

docker-compose up

Run metric script:

docker-compose run metric-script
  • createmetrics: Create the Metrics

(Optional) Open librarycomparisons website command shell:

docker-compose run --service-ports web
  • start: Starts the Django server. The librarycomparison web will run in the 8000 port by default.
  • migrate: Runs Django migrations
  • make: Runs Django makemigrations
  • createsuperuser: Runs Django createsuperuser

To access the website, use http://127.0.0.1:8000/comparelibraries/

3. Stops containers and removes containers, networks, volumes, and images created by up

docker-compose down

Remove volume: docker-compose down -v. Warning: this will permanently delete the contents in the db_data volume, wiping out any previous database you had there

4. Setup Metric Table if you create the docker volumn for the first time

docker exec  librarymetricscripts_db_1 /bin/sh -c  'mysql -uroot -p"mypwd"  libcomp  < docker-entrypoint-initdb.d/metric-setup.sql'

Accessing docker container mysql databases

  1. docker exec -it MyContainer mysql -uroot -pMyPassword
    eg: docker exec -it librarymetricscripts_db_1 mysql -uroot -p"mypwd"
  2. Show MySQL Databases: show databases;
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| libcomp            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
  1. Show MySQL Tables:
use libcomp;
show tables;
  1. Show Table's schema
describe libcomp.Metric;
  1. Show the values of Metric table
select * from libcomp.Metric;

@XiaoleZ XiaoleZ changed the title WIP - Create Dockerfile for LibraryMetricScripts and librarycomparisonswebsite Create Dockerfile for LibraryMetricScripts and Pull librarycomparisonswebsite images from Docker Hub Jan 29, 2021
updatemetrics.sh Outdated

#pull latest repo changes
git pull
file_name="libcomp-bkp-${today}.sql"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we at least put this in a DBBackups folder? Otherwise, it will be lots of files in the current directory

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XiaoleZ So I guess based on our conversation, you should revert back all changes related to updatemetrics.sh (i.e., it should be the original one before your changes since you won't be dealing with it)

docker/start.sh Show resolved Hide resolved
@snadi
Copy link
Contributor

snadi commented Feb 3, 2021

hi @XiaoleZ As discussed, I've created a dockerhub organization https://hub.docker.com/orgs/ualbertasmr and added you as an owner. I've linked the ualberta-smr organization account to it. Can you see if you are able to push the container there now instead of using your personal account? Let me know if there are any issues!

@XiaoleZ
Copy link
Collaborator Author

XiaoleZ commented Feb 3, 2021

@snadi Thank you. I will put the images in the org docker hub

@@ -8,5 +8,6 @@
"MAXSIZE": "1000",
"POPULARITY_OUTPUT_FILE":"scripts/Popularity/popularity_results.txt",
"TIME_SPAN":"365",
"SO_TOKEN":"enter your SO token"
"SO_TOKEN":"enter your SO token",
"OUTPUT_PATH": "scripts/"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When create the docker, set it to "OUTPUT_PATH": "../home/scripts/" The shared charts folder is in home/scripts/charts
Screen Shot 2021-02-12 at 8 33 52 AM

scripts/IssueMetrics/performanceclassifier.py Show resolved Hide resolved
@snadi
Copy link
Contributor

snadi commented Mar 3, 2021

Why are we changing output_path to ../home/scripts/ ?

@snadi
Copy link
Contributor

snadi commented Mar 3, 2021

I get this error when creating the metrics

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/main/scripts/__main__.py", line 4, in <module>
    app.run()
  File "/main/scripts/app.py", line 26, in run
    addlibraries()
  File "/main/scripts/addlibraries.py", line 27, in addlibraries
    if not domain.exists():
  File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 809, in exists
    return self.query.has_results(using=self.db)
  File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/query.py", line 535, in has_results
    return compiler.has_results()
  File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1126, in has_results
    return bool(self.execute_sql(SINGLE))
  File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/usr/local/lib/python3.8/site-packages/MySQLdb/connections.py", line 259, in query
    _mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'libcomp.Domain' doesn't exist")

I think that the domain tables haven't been created yet. So does this mean that the steps need to be done in reverse? That you need to run the migrate for the website first?

@XiaoleZ XiaoleZ requested a review from snadi March 11, 2021 23:37
@XiaoleZ
Copy link
Collaborator Author

XiaoleZ commented Mar 11, 2021

Update the PR: Tested for 2 library and display the charts successfully.
Screen Shot 2021-03-11 at 4 33 37 PM
Screen Shot 2021-03-11 at 4 30 47 PM

@XiaoleZ
Copy link
Collaborator Author

XiaoleZ commented Mar 11, 2021

Why are we changing output_path to ../home/scripts/ ?

Because the charts is in ../home/scripts/ (not in the metricscript or web container). The views.py read the charts from ../home/scripts/ . So the charts can be display on the web.'

I move this change in the code. output_path = ../home/scripts/ is for the docker. If we want to run locally we need to change to the file we store the charts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants