Import ssaw (error)

I use Python 3.11.4 and installed ssaw already but when I imported it I got the error below. Does anyone facts this problem and how to resolve it?


PydanticUserError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import ssaw

File ~\ics\Lib\site-packages\ssaw_init_.py:2
1 from .about import version
----> 2 from .assignments import AssignmentsApi
3 from .export import ExportApi
4 from .headquarters import Client

File ~\ics\Lib\site-packages\ssaw\assignments.py:5
1 from typing import Iterator, List, Optional, Union
3 from sgqlc.operation import Operation
----> 5 from .base import HQBase
6 from .headquarters_schema import (
7 Assignment as GraphQLAssignment,
8 AssignmentsFilter,
9 CalendarEvent,
10 HeadquartersQuery,
11 )
12 from .models import (
13 Assignment,
14 AssignmentHistoryItem,
15 AssignmentList,
16 AssignmentResult,
17 )

File ~\ics\Lib\site-packages\ssaw\base.py:13
10 from sgqlc.types import Arg, Int, Variable
12 from .exceptions import ForbiddenError, GraphQLError, NotAcceptableError, NotFoundError, UnauthorizedError
—> 13 from .headquarters import Client
14 from .headquarters_schema import HeadquartersMutation, HeadquartersQuery
17 GRAPHQL_PAGE_SIZE = 100

File ~\ics\Lib\site-packages\ssaw\headquarters.py:6
3 from requests import Session
5 from .about import title, version
----> 6 from .models import Version
9 class Client(object):
10 “”“Initializes the API client
11
12 :param url: URL of the headquarters app
(…)
16 :param workspace: Name of the workspace. If None, “primary” will be assumed
17 “””

File ~\ics\Lib\site-packages\ssaw\models.py:445
441 mask: Optional[str]
442 value: Optional[str]
→ 445 class NumericQuestion(Question):
446 obj_type: Literal[“NumericQuestion”] = Field(alias=JSON_TYPE_FIELD_NAME,
447 default=“NumericQuestion”,
448 const=True)
449 is_integer: bool = False

File ~\ics\Lib\site-packages\ssaw\models.py:446, in NumericQuestion()
445 class NumericQuestion(Question):
→ 446 obj_type: Literal[“NumericQuestion”] = Field(alias=JSON_TYPE_FIELD_NAME,
447 default=“NumericQuestion”,
448 const=True)
449 is_integer: bool = False
450 value: Optional[float]

File ~\ics\Lib\site-packages\pydantic\fields.py:723, in Field(default, default_factory, alias, alias_priority, validation_alias, serialization_alias, title, description, examples, exclude, include, discriminator, json_schema_extra, frozen, validate_default, repr, init_var, kw_only, pattern, strict, gt, ge, lt, le, multiple_of, allow_inf_nan, max_digits, decimal_places, min_length, max_length, **extra)
721 const = extra.pop(‘const’, None) # type: ignore
722 if const is not None:
→ 723 raise PydanticUserError(‘const is removed, use Literal instead’, code=‘removed-kwargs’)
725 min_items = extra.pop(‘min_items’, None) # type: ignore
726 if min_items is not None:

PydanticUserError: const is removed, use Literal instead

For further information visit Redirecting...

Hi,
I got the following problem.
Traceback (most recent call last):
File “E:\VRHP\Round34\test\download_all.py”, line 2, in
import ssaw
File “C:\Users\Sandeep\AppData\Local\Programs\Python\Python39\lib\site-packages\ssaw_init_.py”, line 2, in
from .assignments import AssignmentsApi
File “C:\Users\Sandeep\AppData\Local\Programs\Python\Python39\lib\site-packages\ssaw\assignments.py”, line 5, in
from .base import HQBase
File “C:\Users\Sandeep\AppData\Local\Programs\Python\Python39\lib\site-packages\ssaw\base.py”, line 15, in
from .headquarters import Client
File “C:\Users\Sandeep\AppData\Local\Programs\Python\Python39\lib\site-packages\ssaw\headquarters.py”, line 5, in
from .models import Version
File “C:\Users\Sandeep\AppData\Local\Programs\Python\Python39\lib\site-packages\ssaw\models.py”, line 456, in
class Variable(BaseModelWithConfig):
File “pydantic\main.py”, line 299, in pydantic.main.ModelMetaclass.new
File “pydantic\fields.py”, line 411, in pydantic.fields.ModelField.infer
File “pydantic\fields.py”, line 342, in pydantic.fields.ModelField.init
File “pydantic\fields.py”, line 451, in pydantic.fields.ModelField.prepare
File “pydantic\fields.py”, line 550, in pydantic.fields.ModelField._type_analysis
File “C:\Users\Sandeep\AppData\Local\Programs\Python\Python39\lib\typing.py”, line 835, in subclasscheck
return issubclass(cls, self.origin)
TypeError: issubclass() arg 1 must be a class

same error over here.
theres an issue with pydantic dependencies i think

ok solved it:

pip install pydantic==1.10.11

need to use and older version of pydantic

1 Like

I install pydantic==1.10.11
I got new error message. I got following error
log_error - URL:9700/graphql: 500 Server Error: Internal Server Error for url:URL::9700/graphql
Traceback (most recent call last):
File “FilePath\download_clinical_all.py”, line 39, in
main()
File “FilePath\download_clinical_all.py”, line 13, in main
for q in ssaw.QuestionnairesApi(clientA).get_list():
File “FilePath\venv\lib\site-packages\ssaw\questionnaires.py”, line 40, in get_list
yield from self._get_full_list(op, ‘questionnaires’, skip=skip, take=take)
File “FilePath\venv\lib\site-packages\ssaw\base.py”, line 99, in _get_full_list
cont = self._make_graphql_call(query, variables={‘take’: page_size, ‘skip’: skip + returned_count})
File “FilePath\venv\lib\site-packages\ssaw\base.py”, line 126, in _make_graphql_call
raise GraphQLError(errors[0][‘message’])
ssaw.exceptions.GraphQLError: 500 Server Error: Internal Server Error for url:URL::9700/graphql

ok, whats the url you are using? check if that url exists and if its the same as your survesolution web access

Hi
Thank you for reply.
I use the folowing Python Script to download the data from our survey.solutions server.
import time
import ssaw
from ssaw import ExportApi
from ssaw import export
from ssaw import QuestionnairesApi
from ssaw.models import ExportJob

def main():
clientA = ssaw.Client(“MyOwn survey.solutions server:9700/”, “AppUser”, “Password”, “Workspace1”)
for q in ssaw.QuestionnairesApi(clientA).get_list():

   args = {
       "questionnaire_identity": str(q.id),
      "export_type": "Stata",
      #  "export_type": "Tabular",
       "interview_status": "All"}


   response = ExportApi(clientA).get(**args)
   if not response:
       # there is no ready export, start a new job
       job = ExportJob(**args)
       job = ExportApi(clientA).start(job)
       # check status every 1 second until the status is not 'Completed'
       job = ExportApi(clientA).get_info(job.job_id)
       while job.export_status != "Completed":
        time.sleep(1)
        job = ExportApi(clientA).get_info(job.job_id)

       # the job was completed, try to download if file was created
       if job.has_export_file:
           response = ExportApi(clientA).get(**args)

if name == “main”:
main()

have you checked that the hostname and port are correct? like check it in a web browser and copy the same one,

Since the specific error code 500 was mentioned, it tells me that this was the actual response. You are expected to have a different error code (perhaps 404) if the query was sent to just some incorrect address or port number.

The server’s log should contain the information on the specifics of the error.

true!

@sandeepbhujbal have you checked if there’s really data to export? on stackoverflow just read that “graphql sends the HTTP error 500 whenever detects there is no data returned.” so, maybe check that the specific data you are trying to export exists on ssolution (try a web via ux export)

Dear team.
Is this a server version problem?
We use the server version 21.01.5 (build 30686).

1 Like

I have uninstalled pydentic and pydantic-core and reinstall pydantic==1.10.9
I work as normal now.

Thanks

1 Like

great! glad it worked

reinstall pydantic==1.10.9 but still error occurs.