Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
pip install -r requirements.txt

- name: Install Node.js dependencies
Expand Down Expand Up @@ -158,6 +159,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
pip install -r requirements.txt
npm ci

Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,12 @@ venv/

docs/_build

# python
__pycache__
*.py[cod]
*.pyo
*.pyd
.Python
*.egg
*.egg-info
*_version.py
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Install python core package
RUN pip install .

# Install gunicorn for production WSGI server
RUN pip install gunicorn

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ python -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows

pip install -r requirements.txt
pip install -r requirements.txt # install the web app requirements (eg. Flask)
pip install -e .[dev] # install the python module containing pathsim utils
```
# Running Application
You can run both frontend and backend at once
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview",
"start:backend": "python -m src.backend",
"start:backend": "python src/backend.py",
"start:both": "concurrently \"npm run dev\" \"npm run start:backend\""
},
"dependencies": {
Expand Down
53 changes: 53 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "setuptools-scm[toml] >= 7.0.5"]
build-backend = "setuptools.build_meta"

[project]
name = "fuel-cycle-sim"
version = "0.1.0"
description = "A Python package for fuel cycle simulation with pathsim integration"
readme = "README.md"
license = {file = "LICENSE"}
authors = [
{name = "Your Name", email = "your.email@example.com"}
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
dependencies = [
"pathsim>=0.7.0",
"matplotlib>=3.7.0",
"numpy>=1.24.0",
"plotly>=6.0",
]

[project.optional-dependencies]
dev = [
"pytest"
]


[project.urls]
Homepage = "https://github.com/yourusername/fuel-cycle-sim"
Documentation = "https://fuel-cycle-sim.readthedocs.io/"
Repository = "https://github.com/yourusername/fuel-cycle-sim.git"
Issues = "https://github.com/yourusername/fuel-cycle-sim/issues"

[tool.setuptools]
packages = ["fuel_cycle_sim"]
package-dir = {"fuel_cycle_sim" = "src/python"}

[tool.setuptools_scm]
write_to = "src/python/_version.py"

[tool.setuptools.package-data]
fuel_cycle_sim = ["templates/*"]
20 changes: 6 additions & 14 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
blinker==1.9.0
click==8.2.1
Flask==3.1.1
flask-cors==6.0.1
itsdangerous==2.2.0
Jinja2==3.1.6
MarkupSafe==3.0.2
Werkzeug==3.1.3
pathsim==0.7.0
matplotlib==3.7.0
numpy==1.24.0
plotly~=6.0
pytest
# Web application dependencies (not needed for core package)
Flask>=3.1.1
flask-cors>=6.0.1

# Development dependencies
sphinx>=4.0.0
docutils>=0.17.0
docutils>=0.17.0
17 changes: 8 additions & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
useEdgesState,
} from '@xyflow/react';
import '@xyflow/react/dist/style.css';
import './App.css';
import './styles/App.css';
import Plot from 'react-plotly.js';
import { getApiEndpoint } from './config.js';
import Sidebar from './Sidebar';
import NodeSidebar from './NodeSidebar';
import { DnDProvider, useDnD } from './DnDContext.jsx';
import ContextMenu from './ContextMenu.jsx';
import EventsTab from './EventsTab.jsx';
import GlobalVariablesTab from './GlobalVariablesTab.jsx';
import { isValidPythonIdentifier } from './utils.js';
import { makeEdge } from './CustomEdge';
import Sidebar from './components/Sidebar';
import NodeSidebar from './components/NodeSidebar';
import { DnDProvider, useDnD } from './components/DnDContext.jsx';
import ContextMenu from './components/ContextMenu.jsx';
import EventsTab from './components/EventsTab.jsx';
import GlobalVariablesTab from './components/GlobalVariablesTab.jsx';
import { makeEdge } from './components/CustomEdge';
import { nodeTypes } from './nodeConfig.js';

// * Declaring variables *
Expand Down Expand Up @@ -59,7 +58,7 @@
}, []);

const onDragStart = (event, nodeType) => {
setType(nodeType);

Check failure on line 61 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

'setType' is not defined

Check failure on line 61 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

'setType' is not defined
event.dataTransfer.setData('text/plain', nodeType);
event.dataTransfer.effectAllowed = 'move';
};
Expand Down Expand Up @@ -216,7 +215,7 @@
setNodes((nds) => [...nds, newNode]);
setNodeCounter((count) => count + 1);
},
[screenToFlowPosition, type, nodeCounter, fetchDefaultValues, setDefaultValues, setNodes, setNodeCounter],

Check warning on line 218 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

React Hook useCallback has an unnecessary dependency: 'setDefaultValues'. Either exclude it or remove the dependency array

Check warning on line 218 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

React Hook useCallback has an unnecessary dependency: 'setDefaultValues'. Either exclude it or remove the dependency array
);

// Function to save a graph to computer with "Save As" dialog
Expand Down Expand Up @@ -898,7 +897,7 @@
return () => {
document.removeEventListener('keydown', handleKeyDown);
};
}, [selectedEdge, selectedNode, copiedNode, duplicateNode, setCopyFeedback]);

Check warning on line 900 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

React Hook useEffect has missing dependencies: 'deleteSelectedEdge' and 'deleteSelectedNode'. Either include them or remove the dependency array

Check warning on line 900 in src/App.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

React Hook useEffect has missing dependencies: 'deleteSelectedEdge' and 'deleteSelectedNode'. Either include them or remove the dependency array

return (
<div style={{ width: '100vw', height: '100vh', display: 'flex', flexDirection: 'column' }}>
Expand Down
4 changes: 0 additions & 4 deletions src/__init__.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import io
from contextlib import redirect_stdout, redirect_stderr

from .convert_to_python import convert_graph_to_python
from .pathsim_utils import make_pathsim_model, map_str_to_object
from fuel_cycle_sim.convert_to_python import convert_graph_to_python
from fuel_cycle_sim.pathsim_utils import make_pathsim_model, map_str_to_object
from pathsim.blocks import Scope, Spectrum

# Sphinx imports for docstring processing
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isValidPythonIdentifier } from './utils.js';
import { isValidPythonIdentifier } from '../utils.js';


import PythonCodeEditor from './PythonCodeEditor';
import './PythonCodeEditor.css';
import '../styles/PythonCodeEditor.css';

export const IdeWithAutocomplete = ({ pythonCode, setPythonCode }) => {
const handleCodeExecution = (result) => {
Expand Down
2 changes: 1 addition & 1 deletion src/NodeSidebar.jsx → src/components/NodeSidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isValidPythonIdentifier } from './utils.js';
import { isValidPythonIdentifier } from '../utils.js';

const makeVarName = (node) => {
// Create a base variable name from the node label
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useCallback } from 'react';
import CodeMirror from '@uiw/react-codemirror';
import { vscodeDark } from '@uiw/codemirror-theme-vscode';
import { python } from '@codemirror/lang-python';
import { getApiEndpoint } from './config.js';
import { getApiEndpoint } from '../config.js';


const PythonCodeEditor = ({
Expand Down
2 changes: 1 addition & 1 deletion src/Sidebar.jsx → src/components/Sidebar.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react';
import { useDnD } from './DnDContext';
import { nodeCategories, getNodeDisplayName } from './nodeConfig.js';
import { nodeCategories, getNodeDisplayName } from '../nodeConfig.js';

export default () => {

Check warning on line 5 in src/components/Sidebar.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.11)

Fast refresh can't handle anonymous components. Add a name to your export

Check warning on line 5 in src/components/Sidebar.jsx

View workflow job for this annotation

GitHub Actions / test (20.x, 3.10)

Fast refresh can't handle anonymous components. Add a name to your export
const [_, setType] = useDnD();
const [expandedCategories, setExpandedCategories] = useState({
'Sources': true,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/main.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import './styles/index.css'
import { App } from './App.jsx'

createRoot(document.getElementById('root')).render(
Expand Down
28 changes: 14 additions & 14 deletions src/nodeConfig.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// Node type definitions and categorization
import { ProcessNode, ProcessNodeHorizontal } from './ProcessNode';
import DelayNode from './DelayNode';
import SourceNode from './ConstantNode';
import { AmplifierNode, AmplifierNodeReverse } from './AmplifierNode';
import IntegratorNode from './IntegratorNode';
import AdderNode from './AdderNode';
import ScopeNode from './ScopeNode';
import StepSourceNode from './StepSourceNode';
import {createFunctionNode} from './FunctionNode';
import DefaultNode from './DefaultNode';
import MultiplierNode from './MultiplierNode';
import { Splitter2Node, Splitter3Node } from './Splitters';
import BubblerNode from './BubblerNode';
import WallNode from './WallNode';
import { ProcessNode, ProcessNodeHorizontal } from './components/nodes/ProcessNode';
import DelayNode from './components/nodes/DelayNode';
import SourceNode from './components/nodes/ConstantNode';
import { AmplifierNode, AmplifierNodeReverse } from './components/nodes/AmplifierNode';
import IntegratorNode from './components/nodes/IntegratorNode';
import AdderNode from './components/nodes/AdderNode';
import ScopeNode from './components/nodes/ScopeNode';
import StepSourceNode from './components/nodes/StepSourceNode';
import {createFunctionNode} from './components/nodes/FunctionNode';
import DefaultNode from './components/nodes/DefaultNode';
import MultiplierNode from './components/nodes/MultiplierNode';
import { Splitter2Node, Splitter3Node } from './components/nodes/Splitters';
import BubblerNode from './components/nodes/BubblerNode';
import WallNode from './components/nodes/WallNode';

// Node types mapping
export const nodeTypes = {
Expand Down
23 changes: 23 additions & 0 deletions src/python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Fuel Cycle Simulation Package

A Python package for fuel cycle simulation with pathsim integration.
"""

from importlib import metadata

try:
__version__ = metadata.version("fuel_cycle_sim")
except Exception:
__version__ = "unknown"

# Import main functions for easy access
from .pathsim_utils import make_pathsim_model, map_str_to_object
from .convert_to_python import convert_graph_to_python

# Define what gets exported when someone does "from python import *"
__all__ = [
"make_pathsim_model",
"map_str_to_object",
"convert_graph_to_python",
]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pathsim import Simulation, Connection
import numpy as np
import matplotlib.pyplot as plt
import src
import fuel_cycle_sim
{# Import macros #}
{% from 'block_macros.py' import create_block, create_integrator_block, create_bubbler_block, create_connections, create_event -%}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 8 additions & 2 deletions test/test_backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from src.pathsim_utils import auto_block_construction, make_connections
from src.custom_pathsim_blocks import Process, Splitter2, Splitter3, Bubbler, Integrator
from fuel_cycle_sim.pathsim_utils import auto_block_construction, make_connections
from fuel_cycle_sim.custom_pathsim_blocks import (
Process,
Splitter2,
Splitter3,
Bubbler,
Integrator,
)

import pathsim.blocks

Expand Down
2 changes: 1 addition & 1 deletion test/test_convert_python.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.convert_to_python import convert_graph_to_python
from fuel_cycle_sim import convert_graph_to_python
import json
import pytest
from pathlib import Path
Expand Down
2 changes: 1 addition & 1 deletion test/test_custom_blocks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pathsim.blocks
from pathsim import Simulation, Connection
from src.custom_pathsim_blocks import Bubbler
from fuel_cycle_sim.custom_pathsim_blocks import Bubbler


def test_bubbler():
Expand Down
2 changes: 1 addition & 1 deletion test/test_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from src.pathsim_utils import make_events
from fuel_cycle_sim.pathsim_utils import make_events


events_data = [
Expand Down
2 changes: 1 addition & 1 deletion test/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.pathsim_utils import make_pathsim_model
from fuel_cycle_sim.pathsim_utils import make_pathsim_model
import json

import pytest
Expand Down
Loading