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

We don't check if string provided as scheduled_execution_date is a genuine datetime #159

Open
2 tasks done
konradkudziagranta opened this issue Nov 14, 2024 · 0 comments · May be fixed by #160
Open
2 tasks done
Labels
bug Something isn't working good first issue Easy to solve for newcomers

Comments

@konradkudziagranta
Copy link
Collaborator

konradkudziagranta commented Nov 14, 2024

🔍 Before submitting the issue

  • I have searched among the existing issues
  • I am using a Python virtual environment

🐞 Description of the bug

It’s possible to provide a scheduled_execution_date in form of , and it works ok when provided value is an actual date but it falis when it only "looks like a date" i.e.: ”2024-1-0”.

In such cases we send it to the serverapi 'as is' and it result in a ‘Bad request’ response:

Traceback (most recent call last):
  File "C:\Automation\STK\STKTests\jobqueue\jobqueue-smoke-test.py", line 252, in <module>
    import_job = api_client.create_job_and_wait(job_request=import_request)
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\jobqueue\_connection.py", line 354, in create_job_and_wait
    job = self.create_job(job_request=job_request)
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\jobqueue\_connection.py", line 398, in create_job
    job_response = self.job_queue_api.create_job(body=job_request._get_job_for_submission())
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\serverapi_openapi\api\job_queue_api.py", line 64, in create_job
    data = self._create_job_with_http_info(body, _return_http_data_only=True)
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\serverapi_openapi\api\job_queue_api.py", line 107, in _create_job_with_http_info
    return self.api_client.call_api(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_api_client.py", line 475, in call_api
    return self.__call_api(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_api_client.py", line 196, in __call_api
    response_data = self.request(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_api_client.py", line 563, in request
    return handle_response(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_util.py", line 380, in handle_response
    raise ApiException.from_response(response)
ansys.openapi.common._exceptions.ApiException: ApiException(400, 'Bad Request')
HTTP response headers: {'Cache-Control': 'private', 'Content-Type': 'application/json; charset=utf-8', 'Server': 'Microsoft-IIS/10.0', 'Persistent-Auth': 'true', 'X-Frame-Options': 'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'Strict-Transport-Security': 'max-age=31536000', 'Date': 'Thu, 14 Nov 2024 12:23:03 GMT', 'Content-Length': '131'}
HTTP response body: {"scheduledExecutionDate":["Could not convert string to DateTime: 2024-1-0. Path 'scheduledExecutionDate', line 1, position 401."]}`

additionally:

“2024-1“ value results in “status: "JobStatus.Succeeded"“ (it shouldn't)
but
but ‘2024’ results in:

Traceback (most recent call last):
  File "C:\Automation\STK\STKTests\jobqueue\jobqueue-smoke-test.py", line 252, in <module>
    import_job = api_client.create_job_and_wait(job_request=import_request)
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\jobqueue\_connection.py", line 354, in create_job_and_wait
    job = self.create_job(job_request=job_request)
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\jobqueue\_connection.py", line 398, in create_job
    job_response = self.job_queue_api.create_job(body=job_request._get_job_for_submission())
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\serverapi_openapi\api\job_queue_api.py", line 64, in create_job
    data = self._create_job_with_http_info(body, _return_http_data_only=True)
  File "C:\Program Files\Python313\Lib\site-packages\ansys\grantami\serverapi_openapi\api\job_queue_api.py", line 107, in _create_job_with_http_info
    return self.api_client.call_api(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_api_client.py", line 475, in call_api
    return self.__call_api(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_api_client.py", line 196, in __call_api
    response_data = self.request(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_api_client.py", line 563, in request
    return handle_response(
  File "C:\Program Files\Python313\Lib\site-packages\ansys\openapi\common\_util.py", line 380, in handle_response
    raise ApiException.from_response(response)
ansys.openapi.common._exceptions.ApiException: ApiException(400, 'Bad Request')
HTTP response headers: {'Cache-Control': 'private', 'Content-Type': 'application/json; charset=utf-8', 'Server': 'Microsoft-IIS/10.0', 'Persistent-Auth': 'true', 'X-Frame-Options': 'SAMEORIGIN', 'X-Content-Type-Options': 'nosniff', 'Strict-Transport-Security': 'max-age=31536000', 'Date': 'Thu, 14 Nov 2024 12:30:17 GMT', 'Content-Length': '127'}
HTTP response body: {"scheduledExecutionDate":["Could not convert string to DateTime: 2024. Path 'scheduledExecutionDate', line 1, position 397."]}`

📝 Steps to reproduce

prepare ExcelImportJobRequest where one of files parameter is a path to a folder, and create a job with it

import_request = jobqueue.ExcelImportJobRequest(
    name = "name",
    description = "description",
    template_file = ".\\myTemplate.xls",
    data_files = [".\\myDataFile.xml"],
    scheduled_execution_date = "2024-1-0",
)

import_job = api_client.create_job_and_wait(job_request=import_request)

💻 Which operating system are you using?

Windows

📀 Which ANSYS version are you using?

ansys-grantami-jobqueue 1.1.0rc0
ansys-grantami-serverapi-openapi 4.0.0
ansys-openapi-common 2.2.0
GRANTA_MIScriptingToolkit 4.1.75

Granta MI b. 25.1.1888

🐍 Which Python version are you using?

3.13

📦 Installed packages

ansys-grantami-jobqueue==1.1.0rc0
ansys-grantami-recordlists==1.3.0rc0
ansys-grantami-serverapi-openapi==4.0.0
ansys-openapi-common==2.2.0
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.4.0
cryptography==43.0.3
filetype==1.2.0
GRANTA_MIScriptingToolkit @ file:///C:/Automation/STK/scripting-toolkit-4-1-75/pip/granta_miscriptingtoolkit-4.1.75-cp38-abi3-win_amd64.whl#sha256=7be8c6e46f63c29c0fde2a30911b2c3a607c5fb6443258b56e77339ca4db58b0
idna==3.10
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
keyring==25.5.0
more-itertools==10.5.0
packaging==24.2
pycparser==2.22
pyparsing==3.2.0
pypiwin32==223
pyspnego==0.11.2
python-dateutil==2.9.0.post0
pywin32==308
pywin32-ctypes==0.2.3
requests==2.32.3
requests-negotiate-sspi==0.5.2
requests_ntlm==1.3.0
six==1.16.0
sspilib==0.2.0
urllib3==2.2.3
@konradkudziagranta konradkudziagranta added the bug Something isn't working label Nov 14, 2024
@konradkudziagranta konradkudziagranta changed the title We don't check if string is provided as scheduled_execution_date is a genuine datetime We don't check if string provided as scheduled_execution_date is a genuine datetime Nov 14, 2024
@Andy-Grigg Andy-Grigg added the good first issue Easy to solve for newcomers label Nov 14, 2024
@Andy-Grigg Andy-Grigg linked a pull request Nov 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Easy to solve for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants