Skip to content

Commit

Permalink
Merge 90bb901 into cb44371
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-salles committed Oct 3, 2022
2 parents cb44371 + 90bb901 commit fd55ae7
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 18 deletions.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
## Development

Use ```make``` commands to ```check_environment```, ```install_requirements```, ```lint```, ```test```, ```migrate```, ```start```, ```migrations``` and ```collectstatic```.


### Commands
| Command | Description |
|--|--|
| make help | Show make commands help
Expand Down Expand Up @@ -78,6 +79,55 @@ Run ```poetry run python ./manage.py start_all_repository_train```
| admin | admin@bothub.it | admin | yes |
| user | user@bothub.it | user | no |

## Development environment setup
A step by step guide on how to run the project locally.
This guide expects that you to:
- Have installed and activated [pyenv](https://github.com/pyenv/pyenv) with the correct Python version for the project;
- Installed [poetry](https://python-poetry.org/) in that environment;
- Installed [redis](https://redis.io/docs/getting-started/installation/) database and it is running;
- Installed and configured [docker](https://docs.docker.com/get-docker/);
- Installed [make](https://gnuwin32.sourceforge.net/packages/make.htm) if you are on Windows.

> All the commands must be executed at the project root.

1. Set up your `.env` file. You can find the expected and default values below or ask a collaborator for the development file in case you don't have one.

2. Create the *bothub* network inside docker:

```docker network create bothub```

3. Run the project's database with docker:

```docker compose up database```

4. Run redis locally:

``` sudo service redis-server restart ```

5. Run engine locally:

```poetry run python manage.py runserver```

6. Run migrations and populate script:

``` poetry run python manage.py migrate ```

``` poetry run python manage.py fill_db_using_fake_data ```

7. Run celery locally:

``` make start_celery ```

8. Run elasticsearch with docker:

``` docker compose up es ```

9. Run elasticsearch indexing:

``` make search_index ```
---


## Production

Expand Down
2 changes: 1 addition & 1 deletion bothub/api/v2/internal/connect_rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def list_classifiers(
params={"project_uuid": project_uuid, "user_email": user_email},
)

return request.json()["data"]
return request.json().get("data", [])

def list_authorizations(self, project_uuid: str, user_email: str) -> List[str]:
classifiers = self.list_classifiers(
Expand Down
16 changes: 8 additions & 8 deletions bothub/api/v2/versionning/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ def update(self, instance, validated_data):
return super().update(instance, validated_data)

def create(self, validated_data): # pragma: no cover
id_clone = validated_data.pop("id")
original_id = validated_data.pop("id")
repository = validated_data.get("repository")
name = validated_data.get("name")
clone = get_object_or_404(RepositoryVersion, pk=id_clone, repository=repository)
original_instance = get_object_or_404(RepositoryVersion, pk=original_id, repository=repository)

instance = self.Meta.model(
clone = self.Meta.model(
name=name,
last_update=clone.last_update,
last_update=original_instance.last_update,
is_default=False,
repository=clone.repository,
repository=original_instance.repository,
created_by=self.context["request"].user,
is_deleted=True,
)
instance.save()
clone.save()
answer_task = celery_app.send_task(
"clone_version", args=[repository.pk, id_clone, instance.pk]
"clone_version", args=[repository.pk, original_id, clone.pk]
)
answer_task.wait()
return instance
return clone
16 changes: 8 additions & 8 deletions bothub/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)

app.conf.beat_schedule = {
"check-training-status": {
"task": "bothub.common.tasks.trainings_check_task",
"schedule": 5.0,
},
# "check-training-status": {
# "task": "bothub.common.tasks.trainings_check_task",
# "schedule": 5.0,
# },
"delete-nlp-logs": {
"task": "bothub.common.tasks.delete_nlp_logs",
"schedule": schedules.crontab(hour="22", minute=0),
Expand All @@ -24,10 +24,10 @@
"task": "bothub.common.tasks.repositories_count_authorizations",
"schedule": schedules.crontab(hour="8", minute=0),
},
"repository-score": {
"task": "bothub.common.tasks.repository_score",
"schedule": schedules.crontab(minute="*/5"),
},
# "repository-score": {
# "task": "bothub.common.tasks.repository_score",
# "schedule": schedules.crontab(minute="*/5"),
# },
}


Expand Down

0 comments on commit fd55ae7

Please sign in to comment.