Unspecified NotImplemented error

We are rewriting our code to use GeoLib to calculate tensions and bearing piles in Dfoundations. We are able to create the .foi file and Dfoundations is able to calculate the file. However, it does not work when sending it to a Dfoundations worker.

The faulty line is creating the analyis model via analysis = DFoundationsAnalysis(input_file). Opening this variable and then the property _job_content gives the following error. I cannot figure out what is not implemented so help is appreciated. I have attached the .foi at the end of this post.

Traceback (most recent call last):
  File "c:\\Users\\vdi\\.vscode\\extensions\\ms-python.python-2022.18.2\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_resolver.py", line 192, in _get_py_dictionary attr = getattr(var, name)
  File "viktor\\external\\external_program.pyx", line 254, in viktor.external.external_program.ExternalProgram._job_content
  File "viktor\\external\\external_program.pyx", line 258, in viktor.external.external_program.ExternalProgram._generate_job_content
  NotImplementedError

Example .foi file
tmppnc2ih3q.foi (103.9 KB)

Hi Vincent,

What error do you get when creating the DFoundationsAnalysis object? I am able to create the object using:

from pathlib import Path
from viktor.core import File
from viktor.external.dfoundations import DFoundationsAnalysis

file_path = Path(__file__).parent / 'your-file.foi'
input_file = File.from_path(file_path)
DFoundationsAnalysis(input_file)

You cannot access _job_content as it is a protected property and is not implemented on this class.

Hey,

When I manually set the DFoundationAnalysis class with the path the of foi file, I get the following error when I execute the analysis:

I have cut the stack trace a bit.

File "C:\DevOps\Python.ParametricDesign\RWZITank\app\tank\program_repository\d_foundation_controller.py", line 98, in _run_worker
    analysis.execute(300)
  File "viktor\external\external_program.pyx", line 335, in viktor.external.external_program.ExternalProgram.execute
  File "viktor\external\external_program.pyx", line 337, in viktor.external.external_program.ExternalProgram.execute
  File "viktor\external\dfoundations.pyx", line 68, in viktor.external.dfoundations.DFoundationsAnalysis._write_job_content
NotImplementedError

The DFoundationsAnalysis class expects a file of type File or BytesIO. Please see the geolib guide how to convert a geolib model to a File object.

Can you check if this solves the problem?

No. The analysis seems to be executed only it returns a noneType. Therefore the second try statement with to set the output_file variable fails with the error UserException raised with: 'NoneType' object is not iterable


# Convert input_file back to bytes object
    with open(input_file, "rb") as file:
        input_file_bytesio = BytesIO(file.read())

    # Prepare the analysis
    analysis = DFoundationsAnalysis(input_file_bytesio)
    # Run the analysis
    for attempt in range(1, MAX_EXECUTION_ATTEMPTS + 1):
        try:
            progress_message(f'attempt {attempt} of {MAX_EXECUTION_ATTEMPTS}')
            analysis.execute(300)
        except ExecutionError as ex:
            raise UserException(str(ex))
        else:
            break
    try:
        # Convert output_file back to string
        output_file = str(analysis.get_output_file().getvalue(), "utf-8")
    except AttributeError:
        output_file = None
    except (Exception, TypeError) as ex:
        raise UserException(str(ex) + " Mogelijk is er geen licentie beschikbaar!")

Can you check the dfoundations-worker logs to see if the job is executed correctly?

I ran it via a local worker and now I found the mistake. The worker gave an understandable error message back. Now it works.

Maybe Viktor can have a look at the error handling because they should just pass the worker error instead of saying NotImplementedError.