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

Exporting courses fails: "not of type 'array'" #3051

Closed
EmanuelLoos opened this issue Sep 3, 2023 · 7 comments
Closed

Exporting courses fails: "not of type 'array'" #3051

EmanuelLoos opened this issue Sep 3, 2023 · 7 comments

Comments

@EmanuelLoos
Copy link

With the current codebase from the main branch with pyyaml 6.0.1 I get the following error upon exporting courses:

root@librelingo:/LibreLingo# yarn exportAllCourses
yarn run v1.22.19
$ ./scripts/exportAllYamlCourses.sh
⏳ Exporting course basque-from-english
    Warning! PyYAML LibYAML C bindings are not installed.
    Course loading still works, but it will be slower.
    For more details, check https://github.com/yaml/pyyaml#Installation
    
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 356, in _load_skill
    jsonschema.validate(data, _get_skill_schema(course))
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/jsonschema/validators.py", line 1307, in validate
    raise error
jsonschema.exceptions.ValidationError: None is not of type 'array'

Failed validating 'type' in schema['properties']['Skill']['properties']['Thumbnails']:
    {'items': {'type': 'string'}, 'type': 'array'}

On instance['Skill']['Thumbnails']:
    None

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/LibreLingo/apps/librelingo_json_export/librelingo_json_export/cli.py", line 27, in main
    course = load_course(input_path)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 538, in load_course
    modules = _load_modules(path, raw_modules, dumb_course)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 450, in _load_modules
    return [_load_module(Path(path) / module, course) for module in modules]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 450, in <listcomp>
    return [_load_module(Path(path) / module, course) for module in modules]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 442, in _load_module
    skills=_load_skills(path, skills, course),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 410, in _load_skills
    return [_load_skill(Path(path) / "skills" / skill, course) for skill in skills]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 410, in <listcomp>
    return [_load_skill(Path(path) / "skills" / skill, course) for skill in skills]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 374, in _load_skill
    raise ValidationError(
librelingo_yaml_loader.yaml_loader.ValidationError: There is an error with the schema at the following file path: ../../courses/basque-from-english/01-Basics/skills/01-basics-1.yaml
Original error message: None is not of type 'array'

Failed validating 'type' in schema['properties']['Skill']['properties']['Thumbnails']:
    {'items': {'type': 'string'}, 'type': 'array'}

On instance['Skill']['Thumbnails']:
    None
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I tried installing lluis-v1.8.1 first but failed to resolve the dependencies because of #3023.
Using the current master branch I was able to solve these dependency issues (or so I think) but now this error occurs.

By the way, if there is a development environment, would there be kind of a production environment as well? How is https://librelingo.app/ configured? I am setting this up on https://ll.emanuel-loos.eu/ and I would like it to be a self-hosted instance that works just like librelingo.app but could not find documentaion for that.

@kantord
Copy link
Owner

kantord commented Sep 6, 2023

Hi, it looks like there is a problem within that course (basque) as it's not matching the expected schema. This has to be fixed in the course itself. For testing purposes you can start by disabling that course in this config file: https://github.com/LibreLingo/LibreLingo/blob/main/config/courses.json

I address the other parts of your issue below as there might be more relevant information: ⬇️

I tried installing lluis-v1.8.1 first but failed to resolve the dependencies because of #3023.

lluis is a nodejs dependency, so that should not be the reason for anything that have to do with the coures and if you experience an issue with it that is probably a separate problem.

By the way, if there is a development environment, would there be kind of a production environment as well? How is https://librelingo.app/ configured?

Yes, there is a production environment which is basically a static site hosting. https://librelingo.app/ is hosted on GitHub pages at the moment.

I am setting this up on https://ll.emanuel-loos.eu/ and I would like it to be a self-hosted instance that works just like librelingo.app but could not find documentaion for that.

After clicking your link I think your instance is already working correctly and set up correctly, and probably further steps are not needed in order to 'fix' your environment. It seems like the problem is actually your original problem, that is the courses are not exported properly which is probably related to errors within the courses or perphaps a bug in the export system.

@EmanuelLoos
Copy link
Author

EmanuelLoos commented Sep 6, 2023

There were similar errors with the Spanish course. I will write more later. With "lluis-v1.8.1" I meant not the nodejs dependency but (what I think is) the latest release of LibreLingo named that way from Github Releases.

@EmanuelLoos
Copy link
Author

root@librelingo:/LibreLingo# yarn run exportCourse spanish-from-english
yarn run v1.22.19
$ ./scripts/exportYamlCourse.sh spanish-from-english
⏳ Exporting course spanish-from-english
    Warning! PyYAML LibYAML C bindings are not installed.
    Course loading still works, but it will be slower.
    For more details, check https://github.com/yaml/pyyaml#Installation
    
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 356, in _load_skill
    jsonschema.validate(data, _get_skill_schema(course))
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/jsonschema/validators.py", line 1307, in validate
    raise error
jsonschema.exceptions.ValidationError: "She's swimming in the sea" is not of type 'array'

Failed validating 'type' in schema['properties']['Phrases']['items']['properties']['Alternative translations']:
    {'items': {'type': 'string'}, 'type': 'array'}

On instance['Phrases'][6]['Alternative translations']:
    "She's swimming in the sea"

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/LibreLingo/apps/librelingo_json_export/librelingo_json_export/cli.py", line 27, in main
    course = load_course(input_path)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 538, in load_course
    modules = _load_modules(path, raw_modules, dumb_course)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 450, in _load_modules
    return [_load_module(Path(path) / module, course) for module in modules]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 450, in <listcomp>
    return [_load_module(Path(path) / module, course) for module in modules]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 442, in _load_module
    skills=_load_skills(path, skills, course),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 410, in _load_skills
    return [_load_skill(Path(path) / "skills" / skill, course) for skill in skills]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 410, in <listcomp>
    return [_load_skill(Path(path) / "skills" / skill, course) for skill in skills]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.cache/pypoetry/virtualenvs/librelingo-json-export-7aADJBEl-py3.11/lib/python3.11/site-packages/librelingo_yaml_loader/yaml_loader.py", line 374, in _load_skill
    raise ValidationError(
librelingo_yaml_loader.yaml_loader.ValidationError: There is an error with the schema at the following file path: ../../courses/spanish-from-english/activities/skills/continuous.yaml
Original error message: "She's swimming in the sea" is not of type 'array'

Failed validating 'type' in schema['properties']['Phrases']['items']['properties']['Alternative translations']:
    {'items': {'type': 'string'}, 'type': 'array'}

On instance['Phrases'][6]['Alternative translations']:
    "She's swimming in the sea"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@EmanuelLoos
Copy link
Author

Thank you for your answers.

It seems like a bug in the export system. Though maybe I just made some mistake setting it up.

@kantord
Copy link
Owner

kantord commented Sep 7, 2023

So now, if you use the latest version of the main branch, this should be "fixed" ™️

You build should not fail, and while some of the courses are not currently enabled because of this, for example the Spanish and Basque course have been fixed.

@EmanuelLoos
Copy link
Author

Thanks, it works now. Any documentation regarding user accounts?

@kantord
Copy link
Owner

kantord commented Sep 8, 2023

Thanks, it works now. Any documentation regarding user accounts?

at the moment user account are broken and there is low key a need to develop a new backend for it. albeit this backend would be more or less a single endpoint endpoint that gives access to a database. If you are interested in working on this, we can have a call! if not you can stay in tuned, eventually it will be fixed

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

No branches or pull requests

2 participants