-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[Bug]: Error When Running the Program from the Command Line #1105
Labels
bug
Something isn't working
Comments
core/db/models/specification.py from copy import deepcopy
from typing import TYPE_CHECKING, Optional, List, Dict, Any
from sqlalchemy import delete, distinct, select, JSON
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Mapped, mapped_column, relationship
from core.db.models import Base
if TYPE_CHECKING:
from core.db.models import ProjectState
class Complexity:
"""Estimate of the project or feature complexity."""
SIMPLE = "simple"
MODERATE = "moderate"
HARD = "hard"
class Specification(Base):
__tablename__ = "specifications"
# ID and parent FKs
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
# Attributes
original_description: Mapped[Optional[str]] = mapped_column(nullable=True)
description: Mapped[str] = mapped_column(default="")
template_summary: Mapped[Optional[str]] = mapped_column(nullable=True)
architecture: Mapped[str] = mapped_column(default="")
# Use JSON type for complex nested structures
system_dependencies: Mapped[List[Dict[str, Any]]] = mapped_column(JSON, default=list)
package_dependencies: Mapped[List[Dict[str, Any]]] = mapped_column(JSON, default=list)
# Use JSON type for templates
templates: Mapped[Optional[Dict[str, Any]]] = mapped_column(JSON, nullable=True)
# Set a default value for complexity
complexity: Mapped[str] = mapped_column(default=Complexity.HARD)
example_project: Mapped[Optional[str]] = mapped_column(nullable=True)
# Relationships
project_states: Mapped[List["ProjectState"]] = relationship(back_populates="specification", lazy="raise")
def clone(self) -> "Specification":
"""
Clone the specification.
"""
clone = Specification(
original_description=self.original_description,
description=self.description,
template_summary=self.template_summary,
architecture=self.architecture,
system_dependencies=deepcopy(self.system_dependencies) if self.system_dependencies else [],
package_dependencies=deepcopy(self.package_dependencies) if self.package_dependencies else [],
templates=deepcopy(self.templates) if self.templates else None,
complexity=self.complexity,
example_project=self.example_project,
)
return clone
@classmethod
async def delete_orphans(cls, session: AsyncSession):
"""
Delete Specification objects that are not referenced by any ProjectState object.
:param session: The database session.
"""
from core.db.models import ProjectState
await session.execute(
delete(Specification).where(~Specification.id.in_(select(distinct(ProjectState.specification_id))))
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version
Command-line (Python) version
Operating System
Ubuntu Linux
What happened?
Error When Running the Program
When trying to run the program using the following command:
I received the following message:
Error Details
It seems that the
MissingGreenlet
error indicates that there is an attempt to call an asynchronous function (await_only()
) in an unexpected place, which may result from not callinggreenlet_spawn
in the correct context.Note: I was working on the program through the command line only.
Request for Help
Can you help me identify the cause of this error and how to fix it? Thank you in advance for any assistance!
The text was updated successfully, but these errors were encountered: