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

creating a new project without a project id an directly activating it crashes. #49

Open
vogt31337 opened this issue Jun 26, 2024 · 2 comments

Comments

@vogt31337
Copy link
Contributor

  • pandahub version: 0.3.3
  • Python version: 3.10
  • Operating System: linux

Description

creating a new project without a project id an directly activating it crashes.

What I Did

ph.create_project(name=project_name, activate=True)

Output

_______________________ ERROR at setup of test_client_io _______________________
[gw0] linux -- Python 3.9.19 /opt/hostedtoolcache/Python/3.9.19/x64/bin/python
self = <pandahub.client.PandaHubClient.PandaHubClient object at 0x7fbe93998310>
    def __init__(self):
        config = os.path.join(Path.home(), "pandahub.config")
        try:
>           with open(config, "r") as f:
E           FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/pandahub.config'
pandahub/client/PandaHubClient.py:16: FileNotFoundError
During handling of the above exception, another exception occurred:
    @pytest.fixture(scope="session")
    def phc():
>       phc = PandaHubClient()
pandahub/test/conftest.py:26: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <pandahub.client.PandaHubClient.PandaHubClient object at 0x7fbe9399[83](https://github.com/e2nIEE/pandahub/actions/runs/9679734197/job/26706352704#step:7:84)10>
    def __init__(self):
        config = os.path.join(Path.home(), "pandahub.config")
        try:
            with open(config, "r") as f:
                d = json.load(f)
        except FileNotFoundError:
>           raise UserWarning("No pandahub configuration file found - log in first")
E           UserWarning: No pandahub configuration file found - log in first
pandahub/client/PandaHubClient.py:19: UserWarning
______________________ ERROR at setup of test_network_io _______________________
[gw1] linux -- Python 3.9.19 /opt/hostedtoolcache/Python/3.9.19/x64/bin/python
    @pytest.fixture(scope="session")
    def ph():
        ph = PandaHub(connection_url="mongodb://localhost:27017")
    
        project_name = "pytest"
    
        if ph.project_exists(project_name):
            ph.set_active_project(project_name)
            ph.delete_project(i_know_this_action_is_final=True)
    
>       ph.create_project(name=project_name, activate=True)
pandahub/test/conftest.py:16: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pandahub/lib/PandaHub.py:244: in create_project
    self.set_active_project_by_id(id)```
@jthurner
Copy link
Collaborator

works for me.

What exactly is failing here? The stack trace is not very helpful. Maybe you get a better trace if you try to reproduce it outside pytest?

From the output you can see that "_id" exists in project_data as this condition must pass to proceed to self.set_active_project_by_id(id).

@jthurner
Copy link
Collaborator

jthurner commented Jun 26, 2024

From the output you can see that "_id" exists in project_data as this condition must pass to proceed to self.set_active_project_by_id(id).

Sorry, misread the code. So id is assigned "inserted_id" from the insert_one response, and then overwritten with _id from project_data. This is unnecessary complicated, see here.

I think these commits should be reverted:
70fac89
e84d1aa
bc1117c

As to why it's failing for you, can you try ph.create_project(name="Test Project", activate=True) from a python shell and post the trace?

The pytest output you posted runs on py39, we are using py310 and py311. All configuration options are defaults, mongo 7.0, pip freeze: pandahub_env.txt

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