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

Import won't work #1177

Open
TellemHD opened this issue May 17, 2024 · 0 comments
Open

Import won't work #1177

TellemHD opened this issue May 17, 2024 · 0 comments
Labels
bug 🪲 Something isn't working

Comments

@TellemHD
Copy link
Contributor

Describe the bug

Importing .sds-FIles doesn't work
(Statisch wird kein Fehler erkannt, aber dynamisch bei der Ausführung)

To Reproduce

  • EIne test.sds-File mit dem Packagenamen test und einem Segment erstellen
  • In einer anderen .sds-Fatei "from test import *" schreiben
  • Das Segment ausführen
2024-05-17 10:38:33.418 [warning] root:Message queue terminated: EOFError()
2024-05-17 10:45:06.706 [warning] .
  warnings.warn(
2024-05-17 10:47:48.353 [warning] .
  warnings.warn(
2024-05-17 10:56:49.427 [debug] root:Received Message: {"type":"program","id":"7f1dda19-c56c-4d88-88bc-4b8c687f589b","data":{"code":{"creditScore":{"gen_creditScore":"# Imports ----------------------------------------------------------------------\r\n\r\nimport safeds_runner\r\nfrom safeds.data.tabular.containers import Table\r\nfrom safeds.data.tabular.transformation import LabelEncoder, OneHotEncoder\r\nfrom safeds.ml.classical.classification import RandomForestClassifier\r\nfrom test.gen_test import calculateAccuracyTemplate\r\n\r\n# Segments ---------------------------------------------------------------------\r\n\r\ndef createClassifierResults(encoded, outputColumn):\r\n    __gen_classifier3 = safeds_runner.memoized_static_call(\r\n        \"safeds.ml.classical.classification.RandomForestClassifier\",\r\n        RandomForestClassifier,\r\n        [],\r\n        {\"number_of_trees\": 200, \"maximum_depth\": None, \"minimum_number_of_samples_in_leaves\": 1},\r\n        []\r\n    )\r\n    __gen_accuracy3 = calculateAccuracyTemplate(encoded, outputColumn, __gen_classifier3)\r\n    __gen_accList = [__gen_accuracy3[0]]\r\n    __gen_nameList = ['RandomForest']\r\n    __gen_f1List = [__gen_accuracy3[1]]\r\n    __gen_precList = [__gen_accuracy3[2]]\r\n    __gen_recList = [__gen_accuracy3[3]]\r\n    __gen_yield_table = safeds_runner.memoized_static_call(\r\n        \"safeds.data.tabular.containers.Table.from_dict\",\r\n        Table.from_dict,\r\n        [{'Name': __gen_nameList, 'Accuracy': __gen_accList, 'F1': __gen_f1List, 'Precision': __gen_precList, 'Recall': __gen_recList}],\r\n        {},\r\n        []\r\n    )\r\n    return __gen_yield_table\r\n\r\ndef calculateAccuracy(data, outputColumn, classifier):\r\n    __gen_receiver_0 = data\r\n    __gen_training, __gen_test = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_0,\r\n        \"split_rows\",\r\n        [0.9],\r\n        {\"shuffle\": True},\r\n        []\r\n    )\r\n    __gen_receiver_1 = __gen_training\r\n    __gen_trainingTable = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_1,\r\n        \"to_tabular_dataset\",\r\n        [outputColumn],\r\n        {\"extra_names\": None},\r\n        []\r\n    )\r\n    __gen_receiver_2 = __gen_test\r\n    __gen_testTable = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_2,\r\n        \"to_tabular_dataset\",\r\n        [outputColumn],\r\n        {\"extra_names\": None},\r\n        []\r\n    )\r\n    __gen_receiver_3 = classifier\r\n    __gen_trained = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_3,\r\n        \"fit\",\r\n        [__gen_trainingTable],\r\n        {},\r\n        []\r\n    )\r\n    __gen_receiver_4 = __gen_trained\r\n    __gen_accuracy = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_4,\r\n        \"accuracy\",\r\n        [__gen_testTable],\r\n        {},\r\n        []\r\n    )\r\n    __gen_receiver_5 = __gen_trained\r\n    __gen_f1 = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_5,\r\n        \"f1_score\",\r\n        [__gen_testTable, 'Good'],\r\n        {},\r\n        []\r\n    )\r\n    __gen_receiver_6 = __gen_trained\r\n    __gen_prec = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_6,\r\n        \"precision\",\r\n        [__gen_testTable, 'Good'],\r\n        {},\r\n        []\r\n    )\r\n    __gen_receiver_7 = __gen_trained\r\n    __gen_rec = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_7,\r\n        \"recall\",\r\n        [__gen_testTable, 'Good'],\r\n        {},\r\n        []\r\n    )\r\n    __gen_yield_result = [__gen_accuracy, __gen_f1, __gen_prec, __gen_rec]\r\n    return __gen_yield_result\r\n\r\n# Pipelines --------------------------------------------------------------------\r\n\r\ndef creditScorePipeline():\r\n    __gen_toRemove = ['ID', 'CustomerID', 'Month', 'Name', 'SSN', 'CreditHistoryAge', 'MonthlyInhandSalary', 'TypeofLoan']\r\n    safeds_runner.save_placeholder('toRemove', __gen_toRemove)\r\n    __gen_toOneHotEncode = ['PaymentBehaviour', 'PaymentofMinAmount', 'Occupation']\r\n    safeds_runner.save_placeholder('toOneHotEncode', __gen_toOneHotEncode)\r\n    __gen_toLabelEncode = ['CreditMix']\r\n    safeds_runner.save_placeholder('toLabelEncode', __gen_toLabelEncode)\r\n    __gen_receiver_0 = safeds_runner.memoized_static_call(\r\n        \"safeds.data.tabular.containers.Table.from_csv_file\",\r\n        Table.from_csv_file,\r\n        [safeds_runner.absolute_path('train.csv')],\r\n        {\"separator\": ','},\r\n        [safeds_runner.file_mtime('train.csv')]\r\n    )\r\n    __gen_table = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_0,\r\n        \"shuffle_rows\",\r\n        [],\r\n        {},\r\n        []\r\n    )\r\n    safeds_runner.save_placeholder('table', __gen_table)\r\n    __gen_receiver_1 = __gen_table\r\n    __gen_receiver_2 = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_1,\r\n        \"remove_columns\",\r\n        [__gen_toRemove],\r\n        {},\r\n        []\r\n    )\r\n    __gen_receiver_3 = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_2,\r\n        \"remove_rows_with_missing_values\",\r\n        [],\r\n        {\"column_names\": None},\r\n        []\r\n    )\r\n    def __gen_lambda_4(r):\r\n        __gen_receiver_5 = r\r\n        __gen_receiver_6 = safeds_runner.memoized_dynamic_call(\r\n            __gen_receiver_5,\r\n            \"get_value\",\r\n            ['Age'],\r\n            {},\r\n            []\r\n        )\r\n        return safeds_runner.memoized_dynamic_call(\r\n            __gen_receiver_6,\r\n            \"lt\",\r\n            [0],\r\n            {},\r\n            []\r\n        )\r\n    __gen_receiver_7 = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_3,\r\n        \"remove_rows\",\r\n        [__gen_lambda_4],\r\n        {},\r\n        []\r\n    )\r\n    def __gen_lambda_8(r):\r\n        __gen_receiver_9 = r\r\n        __gen_receiver_10 = safeds_runner.memoized_dynamic_call(\r\n            __gen_receiver_9,\r\n            \"get_value\",\r\n            ['NumBankAccounts'],\r\n            {},\r\n            []\r\n        )\r\n        return safeds_runner.memoized_dynamic_call(\r\n            __gen_receiver_10,\r\n            \"lt\",\r\n            [0],\r\n            {},\r\n            []\r\n        )\r\n    __gen_removed = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_7,\r\n        \"remove_rows\",\r\n        [__gen_lambda_8],\r\n        {},\r\n        []\r\n    )\r\n    safeds_runner.save_placeholder('removed', __gen_removed)\r\n    __gen_receiver_11 = safeds_runner.memoized_static_call(\r\n        \"safeds.data.tabular.transformation.OneHotEncoder\",\r\n        OneHotEncoder,\r\n        [],\r\n        {\"separator\": '__'},\r\n        []\r\n    )\r\n    __gen_hotEncoded = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_11,\r\n        \"fit_and_transform\",\r\n        [__gen_removed],\r\n        {\"column_names\": __gen_toOneHotEncode},\r\n        []\r\n    )[1]\r\n    safeds_runner.save_placeholder('hotEncoded', __gen_hotEncoded)\r\n    __gen_receiver_12 = safeds_runner.memoized_static_call(\r\n        \"safeds.data.tabular.transformation.LabelEncoder\",\r\n        LabelEncoder,\r\n        [],\r\n        {\"partial_order\": []},\r\n        []\r\n    )\r\n    __gen_labeled = safeds_runner.memoized_dynamic_call(\r\n        __gen_receiver_12,\r\n        \"fit_and_transform\",\r\n        [__gen_hotEncoded],\r\n        {\"column_names\": __gen_toLabelEncode},\r\n        []\r\n    )[1]\r\n    safeds_runner.save_placeholder('labeled', __gen_labeled)\r\n    __gen_result = createClassifierResults(__gen_labeled, 'CreditScore')\r\n    safeds_runner.save_placeholder('result', __gen_result)\r\n","gen_creditScore_creditScorePipeline":"from .gen_creditScore import creditScorePipeline\r\n\r\nif __name__ == '__main__':\r\n    creditScorePipeline()\r\n"}},"main":{"modulepath":"creditScore","module":"creditScore","pipeline":"creditScorePipeline"},"cwd":"c:\\Users\\TimLocke\\OneDrive - Objektkultur Software GmbH\\Desktop\\Uni\\24 Sommersemester\\Projektgruppe Angewandte Softwaretechnologie\\ast-sose24-dsl\\credit_score"}}

Expected behavior

DIe Methdoe sollte ausgeführt werden

Screenshots (optional)

No response

Additional Context (optional)

No response

@TellemHD TellemHD added the bug 🪲 Something isn't working label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant